Click here to Skip to main content
15,885,777 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hey Hi,

I have created CFileDialog object as follows:
C++
CFileDialog dlg(TRUE, NULL, sNewPath, NULL, "Microsoft Excel Files (*.xls)|*.xls||");


Where,
sNewPath is path which consist of the first file name from specified folder with full path.

My version is crashing on following line, if(dlg.DoModal() == IDOK ) in debug as well as in release folder. But not while I am debugging from workspace.

My application is communicating with comm port so I have used timers. After disconnecting the comm port whenever I am trying to access DoModal(), but it's crashing.

My OS is Windows XP pack 3. Same thing when I have tried on Windows 7 its working properly their.

Please anybody help me.
Thanks in advance.
Sheetal.
Posted
Updated 4-Apr-11 22:46pm
v2

maybe a two vertical slash at the end is too much ...

CFileDialog dlg(TRUE, NULL, sNewPath, NULL, "Microsoft Excel Files (*.xls)|*.xls||");
 
Share this answer
 
Comments
Albert Holguin 5-Apr-11 18:49pm    
its supposed to have the two vertical slashes at the end, look up CFileDialog...
Place an AfxMessageBox() to assist in debugging before calling the constructor of dlg and see if sNewPath is what you expect it to be (AfxMessageBox(sNewPath)). Also make sure that dlg is a valid pointer, if its actually crashing on that call, odds are there was a problem with the construction of the CFileDialog and the pointer dlg is invalid.

A couple of things to check:
-sNewPath valid file name? Don't forget strings need "\\" two slashes if you've defined the path by hand...
-Is dlg valid after calling its constructor?
-Is dlg.DoModal() really the call that's crashing the code?
 
Share this answer
 
v2
Comments
sheetal.gawde 6-Apr-11 0:19am    
Hi.. Thanks for your reply.
I have tried putting sNewPath in the AfxMessageBox(sNewPath). It is showing me correct path.
Also I have added messages before and after DoModal(). In this case it is showing me before DoModal message but not the next one.

And the problem I am facing is in the Debug & release folder not when I am running from workspace.

In MSDN, refer following link:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;256329

I have tried this solution also but It still crashes.

Thanks,
Sheetal.
Albert Holguin 6-Apr-11 10:44am    
that bug only applies to constructing a CFileDialog within a custom CFileDialog, don't think that's what you're doing (or are you?)
Albert Holguin 6-Apr-11 10:48am    
by the way, the only thing that changes from your workspace to actually running debug/release is the working directory. could that maybe be causing a problem either with your path or other path dependent code in the same section of software? Is this application a single thread or multiple threads?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900