|
-
March 6th, 2001, 08:10 PM
#1
NT/2000 - Open / Save File Dialog causes application to exit
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.
-
August 14th, 2001, 04:29 AM
#2
Re: NT/2000 - Open / Save File Dialog causes application to exit
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.
-
October 5th, 2001, 10:06 AM
#3
Re: NT/2000 - Open / Save File Dialog causes application to exit
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
-
January 25th, 2006, 05:27 PM
#4
Re: NT/2000 - Open / Save File Dialog causes application to exit
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;
}
-
January 26th, 2006, 02:45 AM
#5
Re: NT/2000 - Open / Save File Dialog causes application to exit
 Originally Posted by Roger65
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.
Well...did you run it under the debugger?
-
January 26th, 2006, 04:11 AM
#6
Re: NT/2000 - Open / Save File Dialog causes application to exit
In debug mode you can't open the dialog box, get access error.
-
January 26th, 2006, 04:52 AM
#7
Re: NT/2000 - Open / Save File Dialog causes application to exit
 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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|