如何屏蔽网页的弹出窗口?(100分)

  • 主题发起人 主题发起人 dmsm
  • 开始时间 开始时间
D

dmsm

Unregistered / Unconfirmed
GUEST, unregistred user!
<br> 如何屏蔽网页的弹出窗口?<br>如何屏蔽网页的弹出窗口,也就是不让弹出窗口出现,而不是出现后关闭?就像超级兔子的 IE保护器里屏蔽<br>弹出窗口那样的功能?<br>谢谢!!! &nbsp; justyear@hotmail.com<br>
 
我也在考虑这个问题,有答案的话请告诉我一声。
 
搬个凳子坐<br>带着纸和笔!~~~<br><br>学习
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, ExtCtrls, StdCtrls,registry;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; Timer1: TTimer;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure Timer1Timer(Sender: TObject);<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormClose(Sender: TObject; var Action: TCloseAction);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; ieclassname:string;<br>&nbsp; deskwidth,deskheight:integer;<br>&nbsp; //strs:tstrings;<br>implementation<br><br>{$R *.dfm}<br>function enumchildprocs(wnd:hwnd;lparam:lparam):boolean;stdcall;<br>var<br>buffer1:array[0..255] of char;<br>begin<br>result:=true;<br>getclassname(wnd,buffer1,255);<br>//strs.Add(buffer1);<br>end;<br>&nbsp;function getiever(key:string):string;<br>&nbsp;var<br>&nbsp;reg:tregistry;<br>&nbsp;begin<br>&nbsp;reg:=tregistry.Create ;<br>&nbsp;reg.RootKey:=HKEY_LOCAL_MACHINE;<br>&nbsp;if reg.OpenKey('software/microsoft/internet explorer',false) then<br>&nbsp;begin<br>&nbsp;try<br>&nbsp;result:=reg.ReadString(key);<br>&nbsp;except<br>&nbsp;result:='';<br>&nbsp;end;<br>&nbsp;end<br>&nbsp;else<br>&nbsp;reg.Free;<br>&nbsp;end;<br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br>h:thandle;<br>t:trect;<br>begin<br>timer1.Interval :=1000;<br>timer1.Enabled :=false;<br>//if getiever('version')[1]='5' then<br>//ieclassname:='CabinetWclass';<br>//if getiever('version')[1]='5' then<br>//ieclassname:='IEFrame';<br>//if getiever('version')[1]='6' then<br>ieclassname:='IEFrame';<br>h:=findwindow('progman',nil);<br>getwindowrect(h,t);<br>deskwidth:=t.Right-t.Left;<br>deskheight:=t.Bottom-t.Top;<br>//strs:=tstringlist.Create; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br>iehandle,iehandle1,ie:thandle;<br>style:longint;<br>ierect:trect;<br>closeie:boolean;<br>i,c,h:integer;<br>ietext:array[0..255] of char;<br>begin<br>c:=0;<br>iehandle:=findwindow(pchar(ieclassname),nil);<br>//iehandle1:=findwindow('IEFrame',nil);<br>//strs.Clear;<br>//enumchildwindows(iehandle,@enumchildprocs,0);<br>{for i:=0 to strs.Count-1 do<br>begin<br>if strs='ReBarWindow32' then<br>begin<br>c:=1;<br>end;<br>end;<br>if c=0 then<br>begin<br>postmessage(iehandle,wm_syscommand,sc_close,0);<br>end;}<br>{iehandle1:=ChildWindowFromPointEx(iehandle,point(50,100),CWP_SKIPINVISIBLE);<br>ie:=FindWindowEx(iehandle,0,nil,'地址(&amp;D)');<br>if ie=0 then<br>begin<br>postmessage(iehandle,wm_syscommand,sc_close,0);<br>end;}<br>if iehandle&lt;&gt;0 then<br>begin<br>closeie:=false;<br>style:=getwindowlong(iehandle,gwl_style);<br>getwindowrect(iehandle,ierect);<br>if ((style and ws_sizebox)&lt;&gt;ws_sizebox) then<br>closeie:=true<br>else<br>with ierect do<br>begin<br>if (right-left&gt;160) and (right-left&lt;500) and (bottom-top&gt;37) and (bottom-top&lt;400) then<br>closeie:=true;<br>end;<br>if ((ierect.right-ierect.left)&gt;(deskwidth+10)) or ((ierect.Bottom-ierect.Top)&gt;(deskheight+10)) &nbsp;then<br>closeie:=true;<br>if &nbsp;((ierect.right-ierect.left)&lt;(deskwidth-10)) and ((ierect.right-ierect.left)&gt;(deskwidth div 2)) and ((ierect.Bottom-ierect.Top)&lt;(deskheight div 2 +30)) then<br>closeie:=true;<br>h:=getwindowtext(iehandle,ietext,256);<br>if (pos('脱机时无法使用',trim(ietext))&gt;0) or (pos('about:blank',ietext)&gt;0) or (pos('无法连接',ietext)&gt;0) or (pos('找不到服务器',ietext)&gt;0) &nbsp;then<br>closeie:=true;<br>end;<br>if closeie=true then<br>postmessage(iehandle,wm_syscommand,sc_close,0);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>timer1.Enabled :=true;<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>timer1.Enabled :=false;<br>end;<br>end.<br>
 
http://mydelphi.8u8.com/ym2.htm<br>Delphi园地<br>广告窗口杀手源码
 
后退
顶部