使用WebBrowser和Delphi 2007进行OLE控件窗口句柄错误 [英] OLE Control window handle error with WebBrowser and Delphi 2007

查看:1091
本文介绍了使用WebBrowser和Delphi 2007进行OLE控件窗口句柄错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周前,我遇到了一个似乎没有逻辑解释的问题。我正在使用Delphi 2007使用AlphaControls和WebBrowser组件放置在表单上构建应用程序。 TWebBrowser 从Web上获取横幅并将其显示在用户界面中。不好的是,一旦显示有横幅的表单,我得到无法获取OLE控件窗口句柄,而浏览器正在窗体外部显示,在左上角桌面的角落。



我基本上一直在尝试弄清楚,但是调试器没有提供太多关于发生了什么的信息(这就是我所得到的:$ 770C4B32的第一次机会异常,异常类 EOleError 带有消息'无法获取OLE控制窗口句柄'。处理project1.exe(3700))。有趣的是,新项目的Form1上相同的 TWebBrowser 没有任何问题。



任何想法将被高度赞赏。

解决方案

是由HTML表单关闭引起的。供应商的论坛显示一些可以解决问题的代码。
http://www.bsalsa.com/forum/showthread.php ?t = 255


在OnWindowClosing事件中将Cancel设置为True,并导航到
空白页,如果是主要的web浏览器。如果您的webbrowser是
弹出窗口,您可能需要关闭EWB所在的表单。




  procedure TForm2.EmbeddedWB1WindowClosing(ASender:TObject; IsChildWindow:WordBool; var Cancel:WordBool); 
begin
取消:= True;
(ASender as TEmbeddedWB).GoAboutBlank;
结束


I have run into an issue a couple of weeks ago that appear to have no logical explanation. I'm building an application with Delphi 2007 using AlphaControls and a WebBrowser component placed on a form. The TWebBrowser fetches a banner from the web and displays it into the UI. bad thing is that as soon as the form with the banner is displayed, I get the "Could not obtain OLE Control window handle", while the browser is being displayed outside of the form, in the top left corner of the desktop.

I've been trying basically anything to figure it out, but the debugger does not provide too much information about what's going on (that's all I get: First chance exception at $770C4B32. Exception class EOleError with message 'Could not obtain OLE control window handle'. Process project1.exe (3700)). Funny thing is that the same TWebBrowser on Form1 of a new project works without any issues.

Any thoughts on that would be highly appreciated.

解决方案

It is caused by the html form being closed. The vendor's forums show some code that will fix the problem. http://www.bsalsa.com/forum/showthread.php?t=255

Set Cancel to True in the OnWindowClosing event and navigate to an empty page if it is the main webbrowser. In case your webbrowser is a popup window, you may want to close the form the EWB is on.

procedure TForm2.EmbeddedWB1WindowClosing(ASender: TObject; IsChildWindow: WordBool; var Cancel: WordBool);
begin
  Cancel := True;
  (ASender as TEmbeddedWB).GoAboutBlank;
end;

这篇关于使用WebBrowser和Delphi 2007进行OLE控件窗口句柄错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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