Hi,
On WinNT and 2000, GetSaveFileName causes my application to exit without any error message. The application just closes abruptly. Works fine on Win95. Any idea what can be the problem?
GetSaveFileName(&ofn);
Thanks in advance.
Printable View
Hi,
On WinNT and 2000, GetSaveFileName causes my application to exit without any error message. The application just closes abruptly. Works fine on Win95. Any idea what can be the problem?
GetSaveFileName(&ofn);
Thanks in advance.
I am having the same problem and getting quite nuts. It only happens when I run the program from the compiler itself. Ran by itself it works fine. Anyone else having this problem?
Paul Paschievici.
I'm not sure if the problem that I encountered is related or not, but when I ran GetOpenFileName/GetSaveFileName it corrupted the stack. Calling those functions didn't cause the crash, but returning from the function that called them crashed. I fixed it by making sure that I defined everything in the OPENFILENAME structure even if it was just setting it to NULL.
Hope that helps.
Brock Atchison
My OS is WinXP Pro(sp2). If I run my program compilied with MSVC 6.0 it works great, the same program compilied with MSVC 8.0 closes the main window and exits. No errors or Send crash to Microsoft. Here is the code:
Code://////////////////////////////////////////////////////////////////////////////
// prompt for file name - used for open and save as
// static function called from app
BOOL PromptForFileName(CString& fileName, BOOL bOpenFileDialog)
{
// TODO: Add your control notification handler code here
CString szFilter = "Windows Bitmap Files (*.BMP; *.DIB) |*.BMP; *.DIB||";
LPSTR title;
char szFile[MAX_PATH];
szFile[0] = '\0';
if (bOpenFileDialog) title="Open image file"; else title="Save image file";
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_hWnd;
ofn.hInstance = hInst;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = szFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = title;
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("bmp");
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK;
ofn.lpfnHook = OFNHookProc;
if (GetSaveFileName(&ofn))
{
m_strPathName = ofn.lpstrFile;
}
else
{
DWORD dwError = ::CommDlgExtendedError();
CString szError;
szError.Format("Open File Dialog Failed, GetFileName returned: %ld", dwError);
#if _MSC_VER < 1400
strcpy(info.szLastError, szError);
#else
strcpy_s(info.szLastError, 256, szError);
#endif
return FALSE;
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
UINT_PTR CALLBACK OFNHookProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
{
case WM_INITDIALOG:
CenterWindow(hwnd);
return 0;
}
return 0;
}
Well...did you run it under the debugger?Quote:
Originally Posted by Roger65
In debug mode you can't open the dialog box, get access error.
Yes....but this is exactly what you want...at that time, you are brought back to the debugger and can then take a look at the callstack etc. to find out what causes the problem...Quote:
Originally Posted by Roger65