zoukankan      html  css  js  c++  java
  • delphi 11 编辑模式 浏览模式

    编辑模式
    浏览模式
    设置焦点
    //在使用前需要Webbrowser已经浏览过一个网页 否则错误
    uses MSHTML;
    ///获取Webbrowser编辑模式里面的内容

    procedure EditMode();
    begin
      (Form1.WebBrowser1.Document as IHTMLDocument2).designMode := 'on';
    end;
    //------------------------------------------------------------------------------

    procedure ViewMode();
    begin
      (Form1.WebBrowser1.Document as IHTMLDocument2).designMode := 'off';
    end;
     
     
    //uses ActiveX;    
    WebBrowser1.OleObject.Document.designMode:='On';//编辑模式
    WebBrowser1.OleObject.Document.designMode:='Off';//浏览模式
        
    (Form1.WebBrowser1.Document as IHTMLDocument2).execCommand('BrowseMode',false,1);
    (Form1.WebBrowser1.Document as IHTMLDocument2).execCommand('EditMode',false,1);
     
     
     
     
    设置焦点 (当Webbrowser处于编辑模式)
    TWebBrowser非常特殊,它从TWinControl继承来的SetFocus方法并不能使得它所包含的文档获得焦点

    //方法1
    procedure TForm1.ToolButton1Click(Sender: TObject);
    begin
       if Form1.WebBrowser1.Document <> nil then
         with WebBrowser1.Application as IOleobject do
            DoVerb(OLEIVERB_UIACTIVATE, nil, WebBrowser1, 0, Handle, GetClientRect());
    end;

    //方法2 Form1OnCreate事件无效
    //OnShow可以
    if WebBrowser1.Document <> nil then
        IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).Focus();




  • 相关阅读:
    2019.6.15刷题统计
    入门组完成情况
    2019.6.14刷题统计
    2019.6.13刷题统计
    绑定与非绑定方法 继承 继承与抽象 查找属性关系 派生与覆盖 访问父类的内容
    23 xml 面向对象
    day22 configparser模块 subprocsee模块 表格
    Python常用模块
    20.logging日志 re正则
    导入模块 包
  • 原文地址:https://www.cnblogs.com/xe2011/p/3876353.html
Copyright © 2011-2022 走看看