问题描述
几周前,我遇到了一个似乎没有逻辑解释的问题。我正在使用Delphi 2007使用AlphaControls和WebBrowser组件放置在表单上构建应用程序。 TWebBrowser
从Web上获取横幅并将其显示在用户界面中。不好的是,一旦显示有横幅的表单,我得到无法获取OLE控件窗口句柄,而浏览器正在窗体外部显示,在左上角桌面的角落。 我基本上一直在尝试弄清楚,但是调试器没有提供太多关于发生了什么的信息(这就是我所得到的:$ 770C4B32的第一次机会异常,异常类 EOleError
带有消息'无法获取OLE控制窗口句柄'。处理project1.exe(3700))。有趣的是,新项目的Form1上相同的 TWebBrowser
没有任何问题。
任何想法将被高度赞赏。
是由HTML表单关闭引起的。供应商的论坛显示一些可以解决问题的代码。
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
procedure TForm2.EmbeddedWB1WindowClosing(ASender: TObject; IsChildWindow: WordBool; var Cancel: WordBool);
begin
Cancel := True;
(ASender as TEmbeddedWB).GoAboutBlank;
end;
这篇关于使用WebBrowser和Delphi 2007进行OLE控件窗口句柄错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!