CFileDialog在调试文件夹中的DoModal()崩溃. [英] CFileDialog crashing at DoModal() in debug folder.

查看:1005
本文介绍了CFileDialog在调试文件夹中的DoModal()崩溃.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了CFileDialog对象,如下所示:

Hey Hi,

I have created CFileDialog object as follows:

CFileDialog dlg(TRUE, NULL, sNewPath, NULL, "Microsoft Excel Files (*.xls)|*.xls||");



哪里,
sNewPath是由指定文件夹中具有完整路径的第一个文件名组成的路径.

我的版本在调试以及发行版文件夹中的if(dlg.DoModal() == IDOK )下一行崩溃.但是当我从工作空间进行调试时不是这样.

我的应用程序正在与comm端口通信,因此我使用了计时器.每当我尝试访问DoModal()时都断开了通讯端口,但它崩溃了.

我的操作系统是Windows XP pack3.当我尝试在Windows 7上正常运行时,也是一样.

请任何人帮助我.
提前谢谢.
Sheetal.



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.

推荐答案

也许最后两个垂直斜线太多了...

CFileDialog dlg(TRUE,NULL,sNewPath,NULL,"Microsoft Excel文件(* .xls)| * .xls ||");
maybe a two vertical slash at the end is too much ...

CFileDialog dlg(TRUE, NULL, sNewPath, NULL, "Microsoft Excel Files (*.xls)|*.xls||");


放置一个AfxMessageBox()有助于调试之前调用dlg的构造函数,看看sNewPath是否是您期望的(AfxMessageBox(sNewPath)).还要确保dlg是有效的指针,如果它实际上在调用中崩溃,则CFileDialog的构造很可能出现问题,并且指针dlg无效.

要检查的几件事:
-sNewPath有效的文件名?如果您手动定义了路径,请不要忘记字符串需要用两个斜杠"\\" ...
-dlg调用其构造函数后是否有效?
-dlg.DoModal()确实是导致代码崩溃的调用吗?
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?


这篇关于CFileDialog在调试文件夹中的DoModal()崩溃.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆