Thread overview
GetOpenFileName
Jan 02, 2004
Scrappy
Jan 02, 2004
Jan Knepper
Jan 02, 2004
Scrappy
Apr 15, 2004
ucampi
January 02, 2004
I need to get the file to open though the common Open File dialog box, so I have
the following with my headers:
#pragma comment(lib, "comdlg32")
Then theres a function called from WM_COMMAND in WndProc like this:
if(LOWORD(wParam)==1003) { openExistingFile(hwnd); }
And the function looks like this:
int openExistingFile(HWND hwnd) {
OPENFILENAME ofn;

ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hInstance = hMainInstance;
ofn.hwndOwner = hwnd;
ofn.Flags = OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn)) { return 1; };

return 0;
}
hwnd is of course the hwnd parameter for WndProc, and hMainInstance is the
hIstance with which the main window was created.  It all compiles fine, but when
I select the appropriate item from the menu the programme closes.  There are no
error messages or such.  Any suggestions?


January 02, 2004
Scrappy wrote:

> I need to get the file to open though the common Open File dialog box, so I have
> the following with my headers:
> #pragma comment(lib, "comdlg32")
> Then theres a function called from WM_COMMAND in WndProc like this: if(LOWORD(wParam)==1003) { openExistingFile(hwnd); }
> And the function looks like this:
> int openExistingFile(HWND hwnd) {
> OPENFILENAME ofn;

memset ( &ofn, 0, sizeof ( ofn ) );  // Might solve the problem.

> 
> ofn.lStructSize = sizeof(OPENFILENAME);
> ofn.hInstance = hMainInstance;
> ofn.hwndOwner = hwnd;
> ofn.Flags = OFN_FILEMUSTEXIST; if(GetOpenFileName(&ofn)) { return 1; };
> 
> return 0;
> }
> hwnd is of course the hwnd parameter for WndProc, and hMainInstance is the
> hIstance with which the main window was created.  It all compiles fine, but when
> I select the appropriate item from the menu the programme closes.  There are no
> error messages or such.  Any suggestions?


-- 
ManiaC++
Jan Knepper
January 02, 2004
It works fine now! Thanks for ur help

In article <bt413l$2mtq$3@digitaldaemon.com>, Jan Knepper says...
>
>Scrappy wrote:
>
>> I need to get the file to open though the common Open File dialog box, so I have
>> the following with my headers:
>> #pragma comment(lib, "comdlg32")
>> Then theres a function called from WM_COMMAND in WndProc like this:
>> if(LOWORD(wParam)==1003) { openExistingFile(hwnd); }
>> And the function looks like this:
>> int openExistingFile(HWND hwnd) {
>> OPENFILENAME ofn;
>
>memset ( &ofn, 0, sizeof ( ofn ) );  // Might solve the problem.
>
>> 
>> ofn.lStructSize = sizeof(OPENFILENAME);
>> ofn.hInstance = hMainInstance;
>> ofn.hwndOwner = hwnd;
>> ofn.Flags = OFN_FILEMUSTEXIST;
>> if(GetOpenFileName(&ofn)) { return 1; };
>> 
>> return 0;
>> }
>> hwnd is of course the hwnd parameter for WndProc, and hMainInstance is the
>> hIstance with which the main window was created.  It all compiles fine, but when
>> I select the appropriate item from the menu the programme closes.  There are no
>> error messages or such.  Any suggestions?
>
>
>-- 
>ManiaC++
>Jan Knepper


April 15, 2004
>if(GetOpenFileName(&ofn)) { return 1; };
maybe you should do something more than a return otherwise it is normal that it does nothing