-
December 6th, 2004, 01:22 PM
#31
Re: CFileDialog crash in Platform SDK
Originally Posted by cilu
No, they are not equivalent. In the first case pFD is created on the heap, in the second case on the stack.
The program should work the same way. Again, programatically, what is the difference? Operator new() or creating an object non-dynamically -- makes no difference. A constructor is called, a call to DoModal() is done, and then the destructor is called. This is for both examples. Operatror new creates an object on the free store, while the other doesn't. Whether the object is created on the heap or stack, it works the same way. The only difference is that you may run out of stack space if you didn't create your object dynamically, and the object is very large in size.
Regards,
Paul McKenzie
-
December 7th, 2004, 02:22 AM
#32
Re: CFileDialog crash in Platform SDK
I also used GetOpenFileName in between and it worked! It shows that there is no problem in PSDK - but with CFileDialog that couldnt work with new PSDK.
Finally, I would recommend seeing lStructSize member - before you assign sizeof() from YOUR code. I did see that CFileDialog ctor initializes it to 76 (whatever the macros defined!!), and then to 88 from our code!
-
December 7th, 2004, 02:09 PM
#33
Re: CFileDialog crash in Platform SDK
I think I figured out why CFileDialog doesn't work. As I've already said, I work on VS6.0 which links CFileDialog related code to COMMDLG.DLL. This is a DLL for the common dialogs. Now, Platform SDK redefines OPENFILENAME but there is no newer DLL for common dialogs in PSDK. The code is still linked with the old DLL which knows nothing about the three new members of that structure. So code crashing is not surprizing. In order to work I should rewrite the entire CFileDialog or probably use the specific DLL from a newer version, such as VS.NET.
-
December 7th, 2004, 11:43 PM
#34
Re: CFileDialog crash in Platform SDK
Does Network Places, My Computer ... appear on the left of dialog box?
I simply mean: can you launch new style dialog box that appears in >=Win2K?
-
December 8th, 2004, 03:05 AM
#35
Re: CFileDialog crash in Platform SDK
Yes, they apear, both with CFileDialog and GetOpenFileName(). With the later there is no first-chance exception. Only CFileDialog has problems.
-
December 15th, 2004, 08:54 PM
#36
CFileDialog crash due to _WIN32_WINNT >= 0x0500 - solution enclosed
I've had this same problem, and found the solution in the MSDN Magazine from August 2000.
Since I happened upon this thread (with recent posts) and no solution posted, I figured I'd post the link.
Here it is:
http://msdn.microsoft.com/msdnmag/is...c/default.aspx
If this link doesn't work, look for the article:
Windows 2000 File Dialog Revisited; Autocompletion and the ACTest Demo App
By Paul DiLascia
From the August 2000 MSDN Magazine, C++ Q&A.
What's amazing is that a bug found over 4 years ago wasn't fixed with a patch, or least a formal KB article post. Thanks, Microsoft.
- John
-
December 16th, 2004, 03:33 AM
#37
Re: CFileDialog crash in Platform SDK
Though I didn't know about that article, I knew about that solution from a project found on CodeProject. However, that was the thing I hoped I don't have to do, so now I know I have too.
Anyway, thanks for the link. It would probably help others.
-
December 16th, 2004, 08:34 AM
#38
Re: CFileDialog crash in Platform SDK
Yes, thanks for pointing that out. I don't think I'll try duplicating Microsoft code, though - that seems a recipe for instant disaster when the operating system gets upgraded.
I'll stick with using the "new" operator, and let the extra bytes languish on the stack.
This brings up a point that's bothered me for a while, though: How do you report a bug to Microsoft if you don't belong to MSDN? The last time I tried, they put a charge of over $200 on my credit card (which was refunded the same day, I hasten to add). Still, it was an off-putting experience, especially considering the cost if it turned out I had missed something important (yes, I have been known to do that).
Regards
Robert Thompson
-
December 16th, 2004, 10:11 AM
#39
Re: CFileDialog crash in Platform SDK
Well, to tell the truth, I didn't implement the MSDN "rewrite" either. I also hate to copy & paste MFC code since that is often asking for trouble down the line.
I just call the raw API function now. The MFC wrapper really isn't very useful anyhow, since the API function is so straight-forward.
Code:
CString SimplePickFile(CWnd *pWnd, LPCTSTR pszTitle)
{
OPENFILENAME ofn;
TCHAR pszFile[MAX_PATH*2];
_tcscpy(pszFile, _T("") );
memset( &ofn, 0, sizeof(ofn) );
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = pWnd ? pWnd->m_hWnd : GetActiveWindow();
ofn.lpstrFile = pszFile;
ofn.nMaxFile = sizeof(pszFile);
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NONETWORKBUTTON | OFN_FILEMUSTEXIST;
ofn.lpstrFilter = _T("All Files (*.*)\0*.*\0Executables (*.exe;*.ocx;*.dll)\0*.exe;*.ocx;*.dll\0");
ofn.lpstrTitle = pszTitle ? pszTitle : _T("Please select a file");
if (GetOpenFileName( &ofn ))
return pszFile;
else
return CString();
}
- John
-
December 16th, 2004, 02:49 PM
#40
Re: CFileDialog crash in Platform SDK
This problem IS fixed in VS70 and MFC70. The problem only happens when you are using VC6 and MFC4.
-
December 17th, 2004, 04:36 PM
#41
Re: CFileDialog crash in Platform SDK
Originally Posted by donmesserli
This problem IS fixed in VS70 and MFC70. The problem only happens when you are using VC6 and MFC4.
Yes, I know...
-
August 30th, 2005, 08:58 PM
#42
Re: CFileDialog crash in Platform SDK
Please check whether ur system have installed Adobe Acrobat Reader 7.0 or later!! .If so, uninstall Adobe Reader and try again. coz I had the same problem and resolved by uninstalling Adobe Reader 7.0.
Thanks,
sabapathy
-
January 26th, 2010, 11:37 AM
#43
Re: CFileDialog crash in Platform SDK
Originally Posted by cilu
Now, there's a real bad news: if I derive CFileDialog I still have that problem:
Code:
CMyFileDialog : public CFileDialog
{
// all the stuff
};
Code:
{
CMyFileDialog *pFD = new CMyFileDialog( TRUE );
pFD->DoModal();
delete pFD; // first-chance exception...
}
Hi cilu,
I am facing the same problem only for IA64 platform. Did you find any resolution for first-chance exception at delete statement?
Thanks,
CBP.
-
January 26th, 2010, 11:42 AM
#44
Re: CFileDialog crash in Platform SDK
Originally Posted by cilu
I have installed Platform SDK Windows Server 2003 (I work in VS 6.0 on WinXP) and I have a problem with CFileDialog.
This code
Code:
void CFileTestView::OnViewFile()
{
CFileDialog dlg(TRUE);
dlg.DoModal();
}
worked just fine before defining _WIN32_WINNT, which I need to use different functions and constants. Now, when I define it
Code:
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
my code just crashes in ~CFileDialog (when dlg does out of scope and is destroyed). Since m_ofn member of CFileDialog depends on this _WIN32_WINT:
Code:
typedef struct tagOFN {
// ...
#if (_WIN32_WINNT >= 0x0500)
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
#endif // (_WIN32_WINNT >= 0x0500)
} OPENFILENAME
I rewrote the code this way:
Code:
void CFileTestView::OnViewFile()
{
CFileDialog dlg(TRUE);
#if (_WIN32_WINNT >= 0x0500)
dlg.m_ofn.pvReserved = NULL;
dlg.m_ofn.dwReserved = 0;
dlg.m_ofn.FlagsEx = 0;
#endif
dlg.DoModal();
}
but I still get a first-chance exception in FileTest.Exe (KERNEL32.dll) 0xC0000005: Access Violation (the usual stuff).
Any ideas? Thanks!
Hi cilu,
I am facing the same problem for IA64 platform. Did you find any resolution for first-chance exception at delete statement?
Thanks,
CBP.
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
|