处理MFC错误消息 [英] Handling MFC error messages

查看:99
本文介绍了处理MFC错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有时,在应用程序启动期间,会弹出错误消息,提示尝试了不受支持的操作".原因通常是我忘记注册OCX文件.尽管这很容易解决,但是要说哪个OCX(在该应用程序中使用了多个OCX)却没有注册却要困难得多.如果进行猜测,或者闯入MFC代码并读取堆栈跟踪信息,直到可以找到控件ID的位置,通常需要很多时间.我在办公室时可以这样做,但是当服务人员尝试升级软件时,我们无法调试.
我想拦截此错误,以便显示类似"blah blah组件未注册"之类的消息.但是,消息框是在MFC代码中生成的,因此我没有机会在捕获到异常之前对其进行处理.我试图逐步检查这段代码,以了解它是否调用了任何虚拟函数来处理错误,但找不到任何虚函数.
我想知道是否可以验证对话框资源以找到所有OCX,并尝试在创建对话框之前尝试通过COM实例化它们,以便我可以输出一条消息,其中包含无法加载的OCX的GUID.顺便说一句,我在谈论对话框,但是实际上有几个应用程序使用文档/视图模型,因此解决方案必须是更通用的解决方案(不仅仅是覆盖CDialog成员函数).我们正在使用带有许多MFC的普通非托管VC ++代码.
感谢您的任何想法或意见.

Hans

Hi all,

sometimes, during startup of an application, an error message pops up saying "attempted an unsupported operation". The reason is usually that I forgot to register an OCX file. While this is easy to fix, it is far more difficult to say which OCX (several OCXs are used in that application) is not registered. It usually required a lot if guesswork, or breaking into MFC code and reading the stack trace up to a point where I can find the control ID. This is ok while I am in office but when service staff are trying to upgrade software we cannot debug.
I''d like to intercept this error so that I can show a message like "The blah blah component is not registered." However the message box is generated in MFC code so that I have no chance to handle an exception before it is caught. I tried to step through this code to find out whether it calls any virtual functions to handle the error, but couldn''t find any.
I wonder whether I can validate the dialog resource to find all OCXs and try to instantiate them via COM before the dialog is created so that I can output a message which contains the GUID of those OCXs which cannot be loaded. By the way, I was talking of dialogs but in fact several applications use the document/view model, so the solution must be a more general one (not just overriding a CDialog member function). We are using plain non-managed VC++ code with lots of MFC.
Thank you for any ideas or comments.

Hans

推荐答案

最好的方法是将ocx移出您的代码,其中大多数可以轻松替换.检查它们是否与IE版本相对应,因此请检查安装的IE. (Windows XP有问题)

此行为还表明您没有适合您的应用程序的安装程序. -> msi

您必须在源代码或资源文件中找到所有ocx并进行全部检查.
The best way is to throw the ocx out of your code, most of them can easily get replaced. Check whether they correspond with an IE Version, so check the installes IE. (a problem with Windows XP)

This behaviour points also that you havent an approbiate setup program for your app. ->msi

you must find all ocx in the sourcecode or the resource file and check them all.


这篇关于处理MFC错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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