Serving the Quantitative Finance Community

 
User avatar
jjyu
Topic Author
Posts: 0
Joined: September 28th, 2005, 12:34 pm

An Excel 2007 SDK question

October 16th, 2008, 1:40 pm

In the sample program "Generic" that comes with Excel 2007 SDK, it shows how to build a user-defined dialog box in a struct.However, the struct itself is pretty much an array of numbers/strings. Does anyone know what they mean?Thanks in advance,Jeff
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

An Excel 2007 SDK question

October 16th, 2008, 4:22 pm

Well, yes I do because I was on the Microsoft Tech beta group for Excel 2007, and looked quite hard at the XLL stuff, and it was me that made the most noise about fixing the documentation.But I'm not alone in this knowledge, since XLL addins are done on the C++ module of the CQF which I teach, so you just need to hire a CQFer A few things you should know...Strings in E12 SDK are LSTRINGS, which aren't C style strings at all, but instead the first byte is the length of the string. Don't argue with me over this, just live with it.In some documentation it shows something of the formchar *RegStr = " G!G%FSFDG";Regstr[0] = (BYTE) strlen (RegStr);The old fashioned cast should alert you to the fact that this is an old dodgy method, and for the last 4 versions of Microsoft C++ literal strings have been read-only, so it crashes. If you aren't at JP Morgan than you probably have a version less than 8 years old, and that code won't work.Functions need to be described to Excel so it knows what parameters are being passed, both in number and type, and whether they are references, values etc.C++ object files (.OBJ, .EXE .DLL, .XLL, .COM, .LIB) do not contaYou also need to say whether the function is threadable since modern versions of Excel (2007 and 2010) are multi threaded, even on machines that only have one core.The struct is in fact a union and does not really exist. It is merely a way of interpreting a block of memory, one reason I subject CQF students to both and high and very low level views.You can use the struct/union and I do this in the CQF, but actually there is no reason why you can't define your own struct as long as it's the same size, and you get nice syntax, you can even wrap it in a class.
Last edited by DominicConnor on October 15th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
jjyu
Topic Author
Posts: 0
Joined: September 28th, 2005, 12:34 pm

An Excel 2007 SDK question

October 16th, 2008, 5:01 pm

Hi Dominic,It would be a long commute for me to come to your class. However, I can be a good reference if that's ok with you.Here is the struct in question:#define g_rgDialogRows 16#define g_rgDialogCols 7static LPWSTR g_rgDialog[g_rgDialogRows][g_rgDialogCols] ={ {L"\000", L"\000", L"\000", L"\003494", L"\003210", L"\025Generic Sample Dialog", L"\000"}, {L"\0011", L"\003330", L"\003174", L"\00288", L"\000", L"\002OK", L"\000"}, {L"\0012", L"\003225", L"\003174", L"\00288", L"\000", L"\006Cancel", L"\000"}, {L"\0015", L"\00219", L"\00211", L"\000", L"\000", L"\006&Name:", L"\000"}, {L"\0016", L"\00219", L"\00229", L"\003251", L"\000", L"\000", L"\000"}, {L"\00214", L"\003305", L"\00215", L"\003154", L"\00273", L"\010&College", L"\000"}, {L"\00211", L"\000", L"\000", L"\000", L"\000", L"\000", L"\0011"}, {L"\00212", L"\000", L"\000", L"\000", L"\000", L"\010&Harvard", L"\0011"}, {L"\00212", L"\000", L"\000", L"\000", L"\000", L"\006&Other", L"\000"}, {L"\0015", L"\00219", L"\00250", L"\000", L"\000", L"\013&Reference:", L"\000"}, {L"\00210", L"\00219", L"\00267", L"\003253", L"\000", L"\000", L"\000"}, {L"\00214", L"\003209", L"\00293", L"\003250", L"\00263", L"\017&Qualifications", L"\000"}, {L"\00213", L"\000", L"\000", L"\000", L"\000", L"\010&BA / BS", L"\0011"}, {L"\00213", L"\000", L"\000", L"\000", L"\000", L"\010&MA / MS", L"\0011"}, {L"\00213", L"\000", L"\000", L"\000", L"\000", L"\021&PhD / Other Grad", L"\0010"}, {L"\00215", L"\00219", L"\00299", L"\003160", L"\00296", L"\015GENERIC_List1", L"\0011"},};I can tell it starts with the length of the string, followed by the content. However, what should I put in [0][0], [0][1]? What is the formatrequirement? Is it documentated? What if I want to change the dialog box somewhat? That's what've bugged me thus far.Jeff
 
User avatar
eehlers
Posts: 0
Joined: May 9th, 2008, 9:50 am

An Excel 2007 SDK question

October 17th, 2008, 11:19 am

Hi Jeff,QuoteOriginally posted by: jjyuI can tell it starts with the length of the string, followed by the content. However, what should I put in [0][0], [0][1]? What is the format requirement? Is it documentated? What if I want to change the dialog box somewhat? That's what've bugged me thus far.The first row of values defines the position, size, and name of the dialog box. Subsequent rows specify the controls to appear in the box, and their properties. The first column specifies the control type, e.g. 1 = OK button, 2 = Cancel button, etc.The values from the g_rgDialog static array are written to XLOPER12 variable xDialog which is passed as an argument to function xlfDialogBox. Like most functions in the Excel C API, xlfDialogBox has in the old macro language an equivalent function - in this case DIALOG.BOX - which is documented in the MACROFUN.HLP file downloadable from the Microsoft website.Regards,Eric
 
User avatar
jjyu
Topic Author
Posts: 0
Joined: September 28th, 2005, 12:34 pm

An Excel 2007 SDK question

October 17th, 2008, 1:40 pm

Thanks! It's very helpful. The reason I find this sample interesting is that the input control can refer to the spreadsheet. I didn't realize the doc can be found in MACROFUN.HLP, it waspart of the Excel 97 SDK. Old, isn't it? Anyway, Thanks very much for the help.Jeff