Can anyone please show me how to use GetOpenFileName() ?
Thanks.
Can anyone please show me how to use GetOpenFileName() ?
Thanks.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
STFWOriginally posted by Devil Panther
Can anyone please show me how to use GetOpenFileName() ?
Thanks.
EDIT: As Eibro says. Code removed as it's copyrighted.
Last edited by _Elixia_; 07-18-2003 at 01:22 PM.
the example does not work, it doesn't even show the dialog box.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
I have a feeling it's your code, and not the examples code. Are you checking the return values of all your calls? If you want another example, check www.sunlightd.com (It's the Windows tutorial, bitmap loading section)
I've placed the code so it will be used when a button is pressed, and changed the hwnd to my handle and everything, but it doesn't show the dialog...
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Please wait while I attempt to use my telepathic powers to read the code off of your PC...
Or, if you don't want to wait as long, post some code.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Code:OPENFILENAME ofn; char filename[256]={0}; ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = "Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*\0*.*\0\0"; ofn.lpstrFile = filename; ofn.nMaxFile = 256; ofn.lpstrTitle = "Browse"; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; GetOpenFileName(&ofn);
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
From The Forgers Win32 API Tutorial
http://www.winprog.org/tutorial/
- SeanCode:OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW ofn.hwndOwner = hwnd; ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "txt"; if(GetOpenFileName(&ofn)) { // Do something usefull with the filename stored in szFileName }
If cities were built like software is built, the first woodpecker to come along would level civilization.
Black Frog Studios
*shrug* works fine for me. The only potential problem I can see is hDlg. Ensure that it's a valid window handle.
A stab in the dark, have you called InitCommonControls() somewhere?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
here is the exact code:
hDlg is the handle of that dialog, I'm calling the GetOpenFileName() from...Code:// in the WM_COMMAND case IDD_SETLOG_BROWSE: { OPENFILENAME ofn; char szFileName[100] = ""; InitCommonControls(); ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW ofn.hwndOwner = hDlg; ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = 100; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = "txt"; if(GetOpenFileName(&ofn)) { MessageBox (NULL, "Message" , " ", 0); } } break;
And I am calling InitCommonControls().
Just... one more thing, I'm using borland C++ 5.5 compiler. And C, not C++, I don't know, I'm just shooting in the dark as well
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
http://www.winprog.org/tutorial/
I've checked out their example code for GetOpenFileName()
I downloaded it (app_two) and tried to use FILE->OPEN, but nothing happened... maybe it's the windows?
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
With the last code you posted, did it put up the messagge box, i.e. is the call to GetOpenFileName() returning TRUE?
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
it returns false... and as I said, it doesn't even show the dialog...
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.