void CMainFrame::OnOptionsSound()
{
CFileDialog FileDlg(TRUE, NULL, NULL /*Default filename*/,
OFN_FILEMUSTEXIST |OFN_HIDEREADONLY|OFN_EXPLORER, NULL, this);
FileDlg.DoModal();
}
I've stripped things down to the bare essentials to try and eliminate
the bug, which is this. When I run the prg in debug mode, I get the
following errors:
CFile exception: fileNotFound, File Unknown, OS error information = 2.
First-chance exception in SectorCreator.exe (KERNEL32.DLL): 0xE06D7363:
Microsoft C++ Exception.
Warning: Uncaught exception in WindowProc (returning 0).
...
Detected memory leaks!
The thread 0x2CC has exited with code 0 (0x0).
Dumping objects ->
C:\Documents and Settings\Administrator\My
Documents\Programs\DTATC\SectorCreator\SectorCreator.cpp(65) : {59}
client block at 0x002F44D8, subtype 0, 928 bytes long. a CObject object
at $002F44D8, 928 bytes long
Object dump complete.
This only occurs if I click Open in the file dialog, not if I select
Cancel. I've tried skipping the MFC wrapper and going directly to
GetOpenFileName(...), as well as a bunch of other things (e.g. using a
hook procedure to override the WM_NOTIFY/CDN_FILEOK and return
non-zero). Apparently there's something going on behind the scenes that
I'm not grasping. Using Process Viewer, I noticed the prg fires off two
new threads when the CFileDialog is invoked (why are two new threads
needed for this?), and then they never get removed (I've never dealt
with threads before so I don't know if they're not supposed to be
removed?).
Any ideas or suggestions would be much appreciated. Thank you.
Regards,
Min
No that's what was frustrating me. I did finally figure it out though. I'd
tried making a skeleton app like you suggested and didn't get this error.
What the problem ended up being is that my app makes a temp file when it
first starts running and then goes to delete it as it shuts down. Well, the
CFile error was apparently from trying to delete a file that couldn't be
found because the path got changed when I opened up the CFileDialog and
clicked OK. So I've made sure to use the full path when I create the temp
file. Thanks Dave for getting me on the right path :-).
Regards,
Min