解决EmbeddedWB弹出页面错误框的问题

使用EmbeddedWB控件的时候,发现有一些错误完全无法用try..except去接,这些错误的提示并非是通过Raize抛出的,而是通过Windows消息传递而来,因此要解决此问题,必须从消息下手。

在EmbeddedWB.pas中,找到重写消息的方法,即TEmbeddedWB.FormWndProc(),其中的代码即是消息的接收,而看其他码,它正是处理了WM_ACTIVATE消息,即有对话框弹出时触发的消息。
即然出错信息也是对话框,那么从此消息跟入就不会有错,继续往下读代码,发现有一句
SetWindowText(Wnd, PChar(S));
直觉告诉我应该在此处下个断点,下了之后调试,果然发现了,这里的变量S就是出错对话框的标题!
那么参数中的Wnd也就是对话框的句柄了。没想到这么简单就直接找到了关键之处

随后要做的,就是把这个对话框关掉了,在对话框显示后,立刻关闭之,这时的一闪而过是用户肉眼无法捕捉的,也不会造成界面闪烁。
于是在 if FDisableErrors.FScriptErr then 下添加一段代码

try
    hButton := FindWindowEx(wnd, 0, 'Button', '&No');
    SendMessage(hButton, BM_Click, 0,0);
except on E: Exception do
end;

这样就直接发送了No这个Button被点击的消息,对话框就自己关掉了
如果是中文版的Windows,只需要把 "&No" 改成 "否(&N)" 即可

如果觉得这么做不放心,要启动出错报告怎么办呢?办法也很简单
在EmbeddedWB控件里,有一个属性的设置,将DisableErrors.ScriptError改成False就好了

转载于:https://www.cnblogs.com/chengxin1982/archive/2009/08/18/1549205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delphi第三方控件EmbeddedWB,这是一个不错的浏览器控件,比Delphi自带的Webbrowser要强悍 EmbeddedWB安装方法: 1.下载压缩包,飘易下载的是EmbeddedWB v14.67.0版本,下载地址:http://www.delphifans.com/SoftView/SoftView_2705.html。 2.解压整个压缩包到 lib\EmbeddedWB 下; 3.复制 lib\EmbeddedWB 下的Packages目录中的EmbeddedWebBrowser_D2007.dpk(因为飘易使用的是DELPHI2007)到Source目录里; 4.用Delphi7开发环境打开 EmbeddedWebBrowser_D2007.dpk 文件,按Optios按钮,作如下调整: Directories/Conditionals标签Unit Output Dir=“D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source”(具体路径自行决定); 5.按Compile 再按Install; 6.不要保存变化了的dpk文件及压缩包; 7.在具体的编译工程时,需检查该源目录(D:\Program Files\CodeGear\RAD Studio\5.0\lib\EmbeddedWB\Source)在 Delphi IDE 的 "Search Path" 路径里(Project -> Options -> irectories/Conditionals -> Search Path); 如果没有,添加这个源目录路径。否则,在使用该控件的时候,出现“File not found: 'SHDocVw_EWB.dcu'” 错误。 8.可以正常使用了。 这里还有一篇别人的“Embedded Web Browser Delphi组件的安装”,不过是把TEmbeddedWB控件安装到 Delphi7 里的。 下面是D2005 installing steps:1.After downloading Unzip the package. 2. Put the folder that contain the package in the path "..:\Borland\BDS\3.0\lib" 3. Open Delphi IDE and press in the menu bar On: File --> "Open" In the open dialog navigate to the path where you store your package to the source folder("..:\Borland\BDS\3.0\lib\EmbeddedWB_D2005\Source"). 5.Choose file name "EmbeddedWebBrowser_D2005.dpk" and press open. 6.In the project manager (in the right corner) point with your mouse on the top file ("EmbeddedWebBrowser_D2005.bdsproj"). Then Right click and choose "Build" 7. And last In the same file & menu Press install. 8. Do not save the package changes. 9. You should make sure that the source folder is in the Delphi IDE "Search Path". If not You must add it.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值