This Question is Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
4 Replies Last post: Aug 2, 2007 1:02 AM by nebuhcaneza  
nebuhcaneza   3 posts since
Jul 24, 2007
Currently Being Moderated

Jul 25, 2007 12:37 AM

Win32 API GetOpenFileNameA

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

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Jul 27, 2007 2:57 PM in response to: nebuhcaneza
Re: Win32 API GetOpenFileNameA

Hello Steve,

 

There is the com.jniwrapper.win32.ui.dialogs.OpenSaveFileDialog class in our WinPack library (http://www.teamdev.com/winpack/index.jsf ) which provides the wrapping of this GetOpenFileName Win32 API. You can run our WinPack demo application: http://www.teamdev.com/downloads/demo/winpackdemo.jnlp , select Dialogs->Open/Save File category to see this integration in action.

 

-Serge

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
3. Aug 1, 2007 6:07 PM in response to: nebuhcaneza
Re: Win32 API GetOpenFileNameA

Hello Steve,

 

Yes, we provide WinPack library (winpack-3.5.jar) in ComfyJ distribution archive. And we also distribute this library along with JNIWrapper for all Windows platforms.

 

-Serge

More Like This

  • Retrieving data ...