Archived

This topic is now archived and is closed to further replies.

MFC and CFileDialog...strange behaviour?

This topic is 5152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been noticing some strange behaviour whenever I create an MFC application and use the CFileDialog class. Basically, if I just create a "shell" application with the MFC app wizard (ie SDI, MDI or Dialog based), add a button, and in the button control code, I show the CFileDialog. ie //Button handler CFileDialog FileDlg (TRUE) FileDlg.DoModal() //End button handler Now, if I exit the application without clicking on the button, everything terminates properly. However, when I click on the button, close the Filedialog window and then exit, the main thread exits with an error code of -1 (after a brief pause). Now, this happens whenever I use the CFileDialog box...if I don''t, my exit code is zero. Has anyone experienced this before? Anyone know the cause? Can I just ignore it? I would really rather not ignore it is indicating some sort of problem. I''m using VC++6.0 with service pack 5 installed. I tried uninstalling VC and reinstalling, but didn''t solve anything. Also, the code runs properly (ie exit code of 0) on an XP machine running VC++6.0 without any service packs installed. This is driving me nuts.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How are you handling the return value from the CFIleDialog.DoModal() call? Are you handling it at all? I would recommend checking the value that call returns. If it is returning a valid value, ie. IDOK or something then I am not sure, if that is the only code added to the shell.

Share this post


Link to post
Share on other sites
The return value is IDOK (as long as I select a file). Strange thing though...I''ve tried it on 3 systems...I get the exit code of -1 on two of the three systems. The only system that doesn''t generate it (that I''ve tried) is an XP system. The two that do are running Win98.

Share this post


Link to post
Share on other sites