CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    5

    Angry Exception with CFileDialog (MFC)

    Hi everyone! I had the following lines of C++ code in my program

    CFileDialog dialog(true);
    CString strFileName=L"";
    INT_PTR nResult = dialog.DoModal();
    if(nResult == IDOK)
    // An exception's spotted here when I made a call to function GetFolderPath()
    // Debug information gives me --> dialog = {CFileDialog hWnd=0x00000000}
    // What's the heck?
    strFileName=dialog.GetFolderPath();

    The problem is: When I execute the program on a PC running Windows XP, there always have an ugly exception which I don't know why it happened. But everything's fine when I copied it to another PC running Windows 7.

    I'm desperate. Would you guy please tell me why?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Exception with CFileDialog (MFC)

    I don't see a call to 'GetFolderPath()'. This:
    Code:
    dialog = {CFileDialog hWnd=0x00000000}
    Is perfectly fine. Once your DoModal call returns, the dialog has been destroyed, and the handle to the dialog window is set to '0'.

    Incidentally, you'd probably get more responses in the
    Visual C++ Programming forum, as this is not a compiler bug.

    Viggy

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