GetOpenFileName() givin me one hell of a time
You need to assign allocate storage and assign lpstrFile yourself, before you call GetOpenFileName(). Plus you aren''t initializing the owning hwnd.
Have a similar problem with commdlg: GetOpenFileName.
I''m relativly sure, that the struct ist correct initialized, because it''s an example from MS. But the dialog does''nt open.
Extended Error Info is 2. Maybe i forgot something (or MS).
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER;
GetOpenFileName(&ofn);
Thanks
christian
I''m relativly sure, that the struct ist correct initialized, because it''s an example from MS. But the dialog does''nt open.
Extended Error Info is 2. Maybe i forgot something (or MS).
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER;
GetOpenFileName(&ofn);
Thanks
christian
Found something...
The string ofn.lpstrFile must have enough space (allocate)
AND !!!!!
the first char must be \0
The string ofn.lpstrFile must have enough space (allocate)
AND !!!!!
the first char must be \0
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement