CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 44 of 44
  1. #31
    Join Date
    Apr 1999
    Posts
    27,449

    Re: CFileDialog crash in Platform SDK

    Quote 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

  2. #32
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    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!
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #33
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #34
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    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?
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #35
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #36
    Join Date
    Jun 2001
    Posts
    20

    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

  7. #37
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  8. #38
    Join Date
    Oct 2002
    Posts
    1,134

    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

  9. #39
    Join Date
    Jun 2001
    Posts
    20

    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

  10. #40
    Join Date
    Dec 2004
    Posts
    2

    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.

  11. #41
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: CFileDialog crash in Platform SDK

    Quote 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...
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  12. #42
    Join Date
    Aug 2005
    Posts
    2

    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

  13. #43
    Join Date
    Jan 2010
    Posts
    2

    Re: CFileDialog crash in Platform SDK

    Quote Originally Posted by cilu View Post
    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.

  14. #44
    Join Date
    Jan 2010
    Posts
    2

    Re: CFileDialog crash in Platform SDK

    Quote Originally Posted by cilu View Post
    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.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured