首页 > 代码库 > delphi中WebBrowser的parent改变时变成空白问题的解决(覆盖CreateWnd和DestroyWnd)
delphi中WebBrowser的parent改变时变成空白问题的解决(覆盖CreateWnd和DestroyWnd)
这段时间在做一个delphi界面打开网页的功能,且此网页所在窗口可完整显示,可缩小到另一个窗口的panel上显示
可是在改变网页所在窗口时,WebBrowser控件变成了空白
上网google了半天,终于在csdn上查到了解决方案:
原帖地址:http://bbs.csdn.NET/topics/200046109
[Delphi] view plain copy
- uses
- SHDocVw, Windows, Controls, Forms, Classes;
- type
- TMyWebBrowser = class(TWebBrowser)
- private
- protected
- ActualHandle: HWND;
- procedure CreateWnd; override;
- procedure DestroyWnd; override;
- public
- end;
- { TMyWebBrowser }
- procedure TMyWebBrowser.CreateWnd;
- begin
- if (ActualHandle <> 0) and IsWindow(ActualHandle) then
- begin
- WindowHandle := ActualHandle;
- ActualHandle := 0;
- Windows.SetParent(WindowHandle, TWinControl(Self).Parent.Handle);
- //Force a resize on the client window
- MoveWindow(WindowHandle, 0, 0, TWinControl(Self).Parent.Width,
- TWinControl(Self).Parent.Height, true);
- end
- else
- inherited;
- end;
- procedure TMyWebBrowser.DestroyWnd;
- begin
- if (csDestroying in ComponentState) then
- inherited
- else
- begin
- //Parent to the Application window which is 0x0 in size
- Windows.SetParent(WindowHandle, Forms.Application.Handle);
- //save the WindowHandle
- ActualHandle := WindowHandle;
- //set it to 0 so Createwnd will be called again...
- WindowHandle := 0;
- end;
- end;
http://blog.csdn.net/youthon/article/details/8450610
delphi中WebBrowser的parent改变时变成空白问题的解决(覆盖CreateWnd和DestroyWnd)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。