首页 > 编程知识 正文

网页弹出对话框,禁止自动弹出网页

时间:2023-05-06 11:13:42 阅读:210095 作者:1617

unit Unit1;

interface

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

type     wb1: TWebBrowser;
    procedure FormCreate(Sender: TObject);
  private
    procedure WMActivate(var Msg: TWMActivate);message WM_ACTIVATE;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure  TForm1.WMActivate(var   Msg:   TWMActivate);
var
    S:String;
    wnd:HWND;
    I:Integer;
begin
  If Msg.Active=0 then
  begin
    wnd := Msg.ActiveWindow;
    I := GetWindowTextLength(wnd);
    SetLength(S,I+1);
    //the   text   of   the   specified   window 's   title   bar
    GetWindowText(Wnd, PChar(S),I+1);
    If Pos( '来自网页的消息', S) > 0 then
    Sendmessage(wnd,WM_CLOSE,0,0);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  wb1.Navigate('file://C:Documents and SettingsAdministratorljdfbxindex.htm');
end;

end.

还有另一种方法,但是能力有限,怎么也看不懂。

IDocHostShowUI接口

http://blog.sina.com.cn/s/blog_4b3906920100npup.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。