Hello,
I am very new to the COM world of things but am very excited about this product and its potential. I am currently trying various things that I would have done in VB6 rather simply. One of those things is invoking the CommonDialog ActiveX control. I have tried several different methods and seem to constantly run into some issue. My first approach was using the Library object to the load the comdlg32.dll and call the function directly. This compiled and ran but no window appeared. I know that the particular function requires a structure OPENFILENAME as a parameter which has two callback params as well. Needless to say I am greatly overwhelmed with this approach and cannot for the life of me get anything to work.
My second approach was using the codegenforcomfyj to wrap the comdlg32.ocx control which created two classes one called CommonDialog and an interface called ICommonDialog. Now both of these looked promising. Now when I try to use these I get a very specific COM exception that I cannot find any documentation whatsoever from anything microsoft related.
If anyone can help me with either approach it would be greatly appreciated. If someone wants to discuss my first approach I can attach some code for it ... it is rather long though since I was creating my own custom structure.
However I will attach a snippet of code using the generated wrappers approach
ComFunctions.coInitialize();
OleFunctions.oleInitialize(); <-- later in this example i would open an excel file and perform some necessary action.
CommonDialog createDialog = new CommonDialog();
ICommonDialog cDlg = createDialog.create(ClsCtx.ALL);
cDlg.setDialogTitle(new BStr("Open"));
cDlg.setInitDir(new BStr("c://"));
cDlg.setFilter(new BStr("Excel Documents *.xls"));
cDlg.setFlags(new Int32(FileOpenConstants.cdlOFNExplorer + FileOpenConstants.cdlOFNLongNames +
FileOpenConstants.cdlOFNCreatePrompt + FileOpenConstants.cdlOFNNoDereferenceLinks));
cDlg.showOpen(); <--- the offender ... throws a COM Exception 0x800A7FFD;
the code in between the declaration of cDlg and the cDlg.showOpen() are merely attempts at passing some info ... same error happens with or without these lines.
In the end I know this particular example may be somewhat pointless since Java can quite easily produce a file open save as dialog. But it was merely a test ... using this product.
Again I thank anyone who may have some insight into this.
Steve