Open Filename dialog won't show.
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
I'm trying to show an Open File dialog but it won't show and i can't figure out what i'm doing wrong, here's the code:
{
OPENFILENAME ofn;
char szFileNames[(MAX_PATH+1)*1000+2];
const char szFilter[] = "MP3 Files (*.mp3)\0" "*.mp3\0";szFileNames\[0\] = 0; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = ghWnd; ofn.lpstrFilter = szFilter; ofn.lpstrCustomFilter = (LPSTR)NULL; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileNames; ofn.nMaxFile = sizeof(szFileNames); ofn.lpstrFileTitle = NULL; ofn.lpstrTitle = (LPSTR)NULL; ofn.Flags = OFN\_ENABLESIZING | OFN\_FILEMUSTEXIST | OFN\_HIDEREADONLY | OFN\_PATHMUSTEXIST | OFN\_ALLOWMULTISELECT | OFN\_EXPLORER; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = "mp3"; GetOpenFileName(&ofn);
Thanks in advance -Rune Svendsen
-
I'm trying to show an Open File dialog but it won't show and i can't figure out what i'm doing wrong, here's the code:
{
OPENFILENAME ofn;
char szFileNames[(MAX_PATH+1)*1000+2];
const char szFilter[] = "MP3 Files (*.mp3)\0" "*.mp3\0";szFileNames\[0\] = 0; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = ghWnd; ofn.lpstrFilter = szFilter; ofn.lpstrCustomFilter = (LPSTR)NULL; ofn.nFilterIndex = 1; ofn.lpstrFile = szFileNames; ofn.nMaxFile = sizeof(szFileNames); ofn.lpstrFileTitle = NULL; ofn.lpstrTitle = (LPSTR)NULL; ofn.Flags = OFN\_ENABLESIZING | OFN\_FILEMUSTEXIST | OFN\_HIDEREADONLY | OFN\_PATHMUSTEXIST | OFN\_ALLOWMULTISELECT | OFN\_EXPLORER; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = "mp3"; GetOpenFileName(&ofn);
Thanks in advance -Rune Svendsen
The dialog shows O.K. for me. The only diference was I tested it with hwndOwner set to NULL. Is the owner window (ghWnd) valid and displayed window? Sonork 100.15206;PavelK