Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 02, 2004 GetOpenFileName | ||||
---|---|---|---|---|
| ||||
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 Re: GetOpenFileName | ||||
---|---|---|---|---|
| ||||
Posted in reply to Scrappy | 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 Re: GetOpenFileName | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jan Knepper | 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 |
Copyright © 1999-2021 by the D Language Foundation