Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have Problems with OPENFILENAME!

Status
Not open for further replies.

AliFessi

Programmer
Jul 3, 2001
12
DE
Hi there,

I need a SaveFile dialog in a non-MFC dll. All the code samples that I have tryed don't work properly under Win2K. Does anyone have a code sample that shows me how to initialize the structure OPENFILENAME before calling GetSaveFileName?

Thanks a lot!!

 
#include<windows.h>
#include<string.h>
class OpenSave:public OPENFILENAMEW
{
private:
public:
OpenSave()
{
hwndOwner=NULL;
lpstrFilter=L&quot;Access database\0*.mdb\0Excell application\0*.xls\0All files\0*.*\0\0&quot;;
lpstrCustomFilter=(wchar_t*)NULL;
nMaxCustFilter=0L;
nFilterIndex=1L;
lpstrFile=new wchar_t[255];
wcscpy(lpstrFile,L&quot;Selected standards.mdb&quot;);
nMaxFile=255;
lpstrFileTitle=new wchar_t[255];
nMaxFileTitle=50;
lpstrInitialDir=L&quot;c:\\\0 &quot;;
lpstrTitle=L&quot;Save your selected standards&quot;;
nFileOffset=0;
nFileExtension=2;
lpstrDefExt=L&quot;*.*&quot;;
lpfnHook=NULL;
lCustData=0;
Flags=OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT; lStructSize=sizeof(OPENFILENAMEW);
}
~OpenSave()
{
delete lpstrFile;
delete lpstrFileTitle;
}
int save()
{
return GetSaveFileNameW(this);
}
int open()
{

return GetOpenFileNameW(this);
}

};
John Fill
1c.bmp


ivfmd@mail.md
 
Well! Thank you John Fill very much for your answer!

Unfortunately I still have the same problem! :-(

When I open the file dialog and click anything: for example the Cancel-button or to go one directory up or down, the dialog hangs up!! and I can not do anything except to kill the process with the task manager!!

Do you have any idea how to solve this problem?!!

Regards!
 
see if there is a CD on your CD-ROM. If so, the process will take some more time. Just eject the CD and see changes. Ion Filipski
1c.bmp


filipski@excite.com
 
No, I have no CD in my CD-ROM.

I think the problem could be hwndOwner or lpfnHook (the members of the structure OPENFILENAMEW)

I wrote an empty hook-procedure. It looks like that:

UINT CALLBACK OpenSave::OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
return false;
}
--

Then I changed the parameter as follow:

Flags= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
lpfnHook = OpenSave::OFNHookProc;
--

The result: I receive a file dialog in an other form: this one where you have to choose first the drive and then choose the file in this drive. The file dialog does'nt hang up! Yeahh!! but I still has an other problem :-( I cannot change the drive!!! That means, if the drive of the InitDirectory is C:\I cannot choose a file in the drive D:\ or in any other drive!

Maybe you can help me if you can answer some of these questions:

1. how can I get the the HWND within the dll?
2. If I should change the hook procedure, how does it must look like?

3. Do you have any idea how I can solve this problem with the drive?

4. Does the code work in your case?! If not, why?!

Note that I want to open the file dialog in the DllMain in the switch statement: &quot;case DLL_PROCESS_ATTACH&quot;. This could be the reason but no idea why!!

Thanks a lot for your advices!!!
 
No, the hook should be NULL. Put a hook only if you want a different type of handling messages. Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top