zoukankan      html  css  js  c++  java
  • webbrower在同一个窗口打开新增窗口

    unit webbrower;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, OleCtrls, SHDocVw;

    type
      TForm1 = class(TForm)
        WebBrowser1: TWebBrowser;
        Button1: TButton;
        WebBrowser2: TWebBrowser;
        Button2: TButton;
        Button3: TButton;
        procedure Button1Click(Sender: TObject);
        procedure WebBrowser1NewWindow2(Sender: TObject; var ppDisp: IDispatch;
          var Cancel: WordBool);
        procedure WebBrowser2BeforeNavigate2(Sender: TObject;
          const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
          Headers: OleVariant; var Cancel: WordBool);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}
      uses Activex;

      const
      OLECMDID_OPTICAL_ZOOM = 63;

    procedure TForm1.Button1Click(Sender: TObject);
    begin

    Webbrowser1.Navigate('http:\\www.hao123.com')   ;
    end;

    procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
      var ppDisp: IDispatch; var Cancel: WordBool);
    begin
        ppDisp := Webbrowser2.Application;
    end;

    procedure TForm1.WebBrowser2BeforeNavigate2(Sender: TObject;
      const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
      Headers: OleVariant; var Cancel: WordBool);
    begin
       WebBrowser1.Navigate(string(URL)); // 再指回WebBrowser1
    Cancel := True
    end;

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      WebBrowser1.GoBack;
    end;

    procedure TForm1.Button3Click(Sender: TObject);

    var
      ZoomIn: OleVariant;
    begin
         ZoomIn := 150;
    //WebBrowser1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, ZoomIn); // TWebBrowser 调用的是 IE, 放缩页面是在 IE7 之后才支持的.

    WebBrowser1.ExecWB(OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT, EmptyParam, EmptyParam);  //打印页面设置

    end;

    initialization
        oleinitialize(nil);
    finalization
        oleuninitialize;
    end.

  • 相关阅读:
    Python的命名空间及作用域
    STM32 RTC时钟的配置
    STM32 输入捕获配置
    stm32 看门狗配置
    led灯的驱动电流和电阻
    STM32中TIMx的映射及其通道
    STM32中断定时,控制LED灯
    STM32 用c语言控制4个LED灯从左向右无限流动
    SYSTEMsyssys.c:33:7: error: expected '(' before 'void' __ASM void MSR_MSP(u32 addr)
    STM32 PWM输出(映射)
  • 原文地址:https://www.cnblogs.com/hssbsw/p/2039839.html
Copyright © 2011-2022 走看看