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

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

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

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

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

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

delphi中WebBrowser的parent改变时变成空白问题的解决(覆盖CreateWnd和DestroyWnd)的更多相关文章

  1. Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决

    Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决 EmbeddedWBWebBrowserDelphi  最近用E ...

  2. delphi 中Adoquery ,在打开时能否让记录指针不移动? [问题点数:40分,结帖人microd]

    delphi 中Adoquery ,在打开时能否让记录指针不移动?由于数据集Adoquery 时,它的针指称动会废时,能否在打开完成之前不让记录指针不移动.打开完毕之后再回复移动? 这样用:self. ...

  3. MFC关于多线程中传递窗口类指针时ASSERT_VALID出错的另类解决 转

    MFC关于多线程中传递窗口类指针时ASSERT_VALID出错的另类解决   在多线程设计中,许多人为了省事,会将对话框类或其它类的指针传给工作线程,而在工作线程中调用该类的成员函数或成员变量等等. ...

  4. delphi中webbrowser的用法

    WebBrowser1.GoHome; //到浏览器默认主页 WebBrowser1.Refresh; //刷新 WebBrowser1.GoBack; //后退 WebBrowser1.GoForw ...

  5. 在IDEA中使用JDBC获取数据库连接时的报错及解决办法

    在IDEA中使用JDBC获取数据库连接时,有时会报错Sat Dec 19 19:32:18 CST 2020 WARN: Establishing SSL connection without ser ...

  6. delphi中Webbrowser疑难问题集锦<转>

    1.获得网页中变量值      htm中<script> var currID=123</script>      程序中可以这么调用 id := Form1.WebBrows ...

  7. delphi中WEBBrowser网页html相互调用(一)

    1.基本操作1.1.激活 var doc,url:Olevariant ; begin url:='about:blank' ;//或者一个有实际意义的url WebBrowser1.Navigate ...

  8. Delphi中Owner和Parent的区别

    Owner为创建者,Parent为容器 他们的类型不同,Owner为TComponent(元件),Parent为TWinControl(窗体控件) Parent属性是指构件的包容器,构件只能在此范围内 ...

  9. C# Winform 中webBrowser显示html内容时禁止错误提示的方法

    在winform中有一个控件可以显示html的内容,该控件就是webbrowser,设置它的DocumenText属性为HTML的内容即可. 在使用WebBrowser做UI的时候,我们有时不希望里面 ...

随机推荐

  1. [Angular] NgRx/effect, why to use it?

    See the current implementaion of code, we have a smart component, and inside the smart component we ...

  2. jquery-3 jquery选择器

    jquery-3 jquery选择器 一.总结 一句话总结:选择器使用的时候可以结合参考手册,里面都已经详细归类好了.(多用才能熟啊) 1.$(:input).css({'color':'#98765 ...

  3. [Flow] Declare types for application

    In Flow, you can make global declarion about types. Run: flow init It will generate .flowconfig file ...

  4. 探险 - 树型dp(背包)/多叉树转二叉树

    题目大意: 国家探险队长 Jack 意外弄到了一份秦始皇的藏宝图,于是,探险队一行人便踏上寻宝之旅,去寻找传说中的宝藏. 藏宝点分布在森林的各处,每个点有一个值,表示藏宝的价值.它们之间由一些小路相连 ...

  5. [GeekBand] 设计模式之观察者模式学习笔记

    本文参考文献::GeekBand课堂内容,授课老师:李建忠 :网络资料: http://blog.csdn.net/hguisu/article/details/7556625 本文仅作为自己的学习笔 ...

  6. 【BZOJ 1023】[SHOI2008]cactus仙人掌图

    [题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1023 [题意] [题解] 如果不考虑有环的情况; 那么有一个经典的求树的直径的方法; ...

  7. 【BZOJ 1037】[ZJOI2008]生日聚会Party

    [题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1037 [题意] [题解] /* 设f[i][j][k][l] 表示前i个人中,有j个男 ...

  8. Power aware dynamic scheduling in multiprocessor system employing voltage islands

    Minimizing the overall power conservation in a symmetric multiprocessor system disposed in a system- ...

  9. Read-Copy Update Implementation For Non-Cache-Coherent Systems

    A technique for implementing read-copy update in a shared-memory computing system having two or more ...

  10. 利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统

    原文:利用WPF建立自己的3d gis软件(非axhost方式)(十二)SDK中的导航系统 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV0bPew ...