Written by Administrator
   
 

  Since TWebBrowser is inherited methods from TControl, you may think immediately to use the method 'SetFocus' to make it get the focus. Unfortunately, it does not work. So we have to find out some way else to accomplish this task. I have found three ways to make it focused.

1. The first way need to write a function to get it.

  procedure TForm1.WebBrowserSetFocus;   begin    if WebBrowser1.Document nil then     with WebBrowser1.Application as IOleobject do      DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect);   end;

2. Another easy way to get it.

  if WebBrowser1.Document nil then    IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).focus

3. The best way I found to get it.

  if WebBrowser1.Document nil then    IHTMLWindow4(WebBrowser1.Document).focus

Ok, when you need to determind if a webbrowser has the focus, use the following code:

  if IHTMLWindow4(WebBrowser1.Document).hasfocus then

How to make TWebBrowser get focus in Delphi的更多相关文章

  1. .NET平台上的编译器不完全列表(转别)

    http://www.cnblogs.com/william_fire/archive/2005/05/15/155800.html最近因为开发需要,要研究一下.NET上基于C#扩展的编译器实现的框架 ...

  2. Delphi TWebBrowser

    Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application      如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...

  3. Delphi TWebBrowser编程简述(转帖)

    Delphi 3开始有了TWebBrowser构件,不过那时是以ActiveX控件的形式出现的,而且需要自己引入,在其后的4.0和5.0中,它就在封装好shdocvw.dll之后作为Internet构 ...

  4. delphi 从TWebBrowser WebBrowser得到全部html源码

    delphi 从TWebBrowser WebBrowser得到全部html源码 http://blog.csdn.net/webouse/article/details/3912174   网上查询 ...

  5. delphi 操作 TWebBrowser 实现自动填表(JQuery脚本与 OleVariant 方法)

    版本:DELPHI XE8 操作交通银行信用卡申请表单(2016-03-23),网址如下: https://creditcardapp.bankcomm.com/applynew/front/appl ...

  6. Delphi 中TWebBrowser的扩展控件TExWebBrowser

    主要扩展了3D界面.右键菜单.是否显示图片.是否支持JAVA等功能. 代码如下: unit ExtWebBrowser; interface uses Windows, SysUtils, Class ...

  7. Delphi处理TWebBrowser的Close事件

    当TWebBrowser控件访问的 Web 页上的脚本调用window.close方法时,TWebBrowser控件可能会在窗体中消失.我们的程序应该对此作出反应,否则再次访问TWebBrowser控 ...

  8. Delphi中TWebBrowser中注入Js

    最近帮朋友做一个软件,其中要自动化某网页中的操作,最简的操作是调用自己写的代码. 代码如下: procedure TForm1.Button2Click(Sender: TObject);var  i ...

  9. delphi中webbrowser的用法

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

随机推荐

  1. javaweb乱码(tomcat服务器)

    et提交  :<Connector protocol="HTTP/1.1" port="80" redirectPort="8443" ...

  2. source insight Confirm by typing ‘yes' below"、"has been changed outside of the editor. Do you want to reload the file?"、“

    阅读内核代码习惯和喜欢使用source insight.如果能在source insight上修改内核代码,同时又不需要把修改的内核代码再拷贝到虚拟ubuntu上去那就方便了.于是想通过用samba与 ...

  3. bootstrap基础学习九篇

    现在学学bootstrap响应式实用工具 Bootstrap 提供了一些辅助类,以便更快地实现对移动设备友好的开发.这些可以通过媒体查询结合大型.小型和中型设备,实现内容对设备的显示和隐藏. 需要谨慎 ...

  4. C# Expression 树转化为SQL语句(一)

    sql有有四中基本语句,分别是增删改查,在建立model后如何生成这四中sql语句,降低开发时间. 我们先模拟出一张学生表: public class Student { public int id ...

  5. Unicode UTF-8 转换

    Unicode是类似“U+4E25”或“\u4E25”的编码方式,很多情况下是4个十六进制的数,有时候不止. Unicode编码系统可分为编码方式和实现方式两个层次: 编码方式:“严”的Unicode ...

  6. 添加RichEdit控件后导致MFC对话框程序无法运行的解决方法

    新建一个基于对话框的MFC程序,对话框上添加了RichEdit控件,编译成功后无法运行起来,Debug版本与Release版本均不行! Windbg分析结果: WARNING: Stack unwin ...

  7. WPF界面框架的设计

    http://www.cnblogs.com/baihmpgy/p/osgi_muinavtree_fx.html

  8. java中的字符集和编码

    前言 上次对计算机中的“字符集”和“编码”分别进行了总结,并指出二者之间的区别,不要搞混了,不清楚的再回到上一章看一下.今天再总结下java中是如何使用字符集(主要是Unicode字符集,其他常用字符 ...

  9. quartz定时任务配置

    参考:http://www.cnblogs.com/kay/archive/2007/11/02/947372.html Quartz是一个强大的企业级任务调度框架,Spring中继承并简化了Quar ...

  10. VMware虚拟机NAT(地址转换模式)

    转载于:https://www.linuxidc.com/Linux/2016-09/135521p2.htm 二.NAT(地址转换模式)   刚刚我们说到,如果你的网络ip资源紧缺,但是你又希望你的 ...