zoukankan      html  css  js  c++  java
  • delphi中WebBrowser的parent改变时变成空白问题的解决(覆盖CreateWnd和DestroyWnd)

    这段时间在做一个delphi界面打开网页的功能,且此网页所在窗口可完整显示,可缩小到另一个窗口的panel上显示

    可是在改变网页所在窗口时,WebBrowser控件变成了空白

    上网google了半天,终于在csdn上查到了解决方案:

    原帖地址:http://bbs.csdn.NET/topics/200046109

    [Delphi] view plain copy
     
    1. uses  
    2.   SHDocVw, Windows, Controls, Forms, Classes;  
    3.   
    4. type  
    5.   TMyWebBrowser = class(TWebBrowser)  
    6.   private  
    7.   protected  
    8.     ActualHandle: HWND;  
    9.     procedure CreateWnd; override;  
    10.     procedure DestroyWnd; override;  
    11.   public  
    12.   end;  
    13.   
    14.   
    15. { TMyWebBrowser }  
    16. procedure TMyWebBrowser.CreateWnd;  
    17. begin  
    18.   if (ActualHandle <> 0) and IsWindow(ActualHandle) then  
    19.   begin  
    20.     WindowHandle := ActualHandle;  
    21.     ActualHandle := 0;  
    22.     Windows.SetParent(WindowHandle, TWinControl(Self).Parent.Handle);  
    23.     //Force a resize on the client window  
    24.     MoveWindow(WindowHandle, 0, 0, TWinControl(Self).Parent.Width,  
    25.       TWinControl(Self).Parent.Height, true);   
    26.   end  
    27.   else  
    28.     inherited;  
    29. end;  
    30.   
    31. procedure TMyWebBrowser.DestroyWnd;  
    32. begin  
    33.   if (csDestroying in ComponentState) then  
    34.     inherited  
    35.   else  
    36.   begin  
    37.     //Parent to the Application window which is 0x0 in size  
    38.     Windows.SetParent(WindowHandle, Forms.Application.Handle);  
    39.     //save the WindowHandle  
    40.     ActualHandle := WindowHandle;   
    41.     //set it to 0 so Createwnd will be called again...  
    42.     WindowHandle := 0;   
    43.   end;  
    44. end;  

    http://blog.csdn.net/youthon/article/details/8450610

  • 相关阅读:
    〖Linux〗-- 复制、用户和组操作、权限更改
    〖Linux〗-- 文本结构和基本命令
    〖Demo〗-- ATM
    〖Python〗-- 脚本目录规范
    二、配置文件
    一、SpringBoot入门
    File--字节流--字符流
    File--字节流--字符流
    SpringBoot快速搭建流程
    SpringBoot快速搭建流程
  • 原文地址:https://www.cnblogs.com/findumars/p/7230686.html
Copyright © 2011-2022 走看看