这段时间在做一个delphi界面打开网页的功能,且此网页所在窗口可完整显示,可缩小到另一个窗口的panel上显示
可是在改变网页所在窗口时,WebBrowser控件变成了空白
上网google了半天,终于在csdn上查到了解决方案:
原帖地址:http://bbs.csdn.NET/topics/200046109
- uses
- SHDocVw, Windows, Controls, Forms, Classes;
-
- type
- TMyWebBrowser = class(TWebBrowser)
- private
- protected
- ActualHandle: HWND;
- procedure CreateWnd; override;
- procedure DestroyWnd; override;
- public
- end;
-
-
- procedure TMyWebBrowser.CreateWnd;
- begin
- if (ActualHandle <> 0) and IsWindow(ActualHandle) then
- begin
- WindowHandle := ActualHandle;
- ActualHandle := 0;
- Windows.SetParent(WindowHandle, TWinControl(Self).Parent.Handle);
-
- 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
-
- Windows.SetParent(WindowHandle, Forms.Application.Handle);
-
- ActualHandle := WindowHandle;
-
- WindowHandle := 0;
- end;
- end;
-
http://blog.csdn.net/youthon/article/details/8450610
|
请发表评论