Search code examples
c++mfcvisual-studio-2005cfiledialog

CFileDialog freezes when launched from Modeless Dialog


I'm attempting to call CFileDialog to allow the user to select a file.

My program is a MFC application and I am using VS2005.

Here is my problem:

I have main View that creates a modeless dialog box. In this dialog box I have a menu item that makes a simple CFileDialog call:

CFileDialog dlgFile(true);
dlgFile.DoModal();

But the program always hangs on the DoModal. The program does not respond to commands and Task manager says it has stopped responding.

Other interesting pieces of information:

  • This has only been observed on Windows 8, Windows 7 machines seem to be unaffected.
  • I created a new project with the same basic View->modeless dialog->CFileDialog scheme and it worked just fine.
  • When I make a call to MessageBox, it appears behind the dialog box (I have to hit alt to get it up front), but the program is still responsive.
  • If I make the same CFileDialog call in the main View, it pops up without any problem.
  • Another annoying issue that may or may not be related to this: When the CFileDialog call is working (on Win 7), selecting "computer" in the browse window shows a blank white screen (Everything else works fine).

The closest questions I could find is this: Why does CFileDialog::DoModal() Hang? However, I don't use threads (At least I'm 95% sure I don't, this isn't just my project). Is my project automatically being threaded? If so, how can I make sure that isn't causing me problems?


Solution

  • I've the same problem in VS2008. Try to set to false the last parameter in CFileDialog constructor (bVistaStyle)