//writer by liguang<br>//in 2000-03-17 <br>unit ligwin1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Label1: TLabel;<br> Label2: TLabel;<br> procedure FormCreate(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> private<br> { Private declarations }<br> control,KeyId:integer;<br> hotkeyid:ATOM;<br> public<br> { Public declarations }<br> procedure WMHOTKEY(var Msg:TMessage);message WM_HOTKEY;<br> end;<br><br>var<br> Form1: TForm1;<br> ThisUrl
Char;<br><br>implementation<br><br>{$R *.DFM}<br><br><br>function EnumChildWindowsProc(H:HWnd;lparam:longint):Boolean;stdcall;<br>var<br> Buffer: array[0..10] of Char;<br>begin<br> Result:=True;<br> GetClassName(h,buffer,10);<br> if trim(StrPas(Buffer))='Edit' then<br> begin<br> SendMessage(h,WM_GETTEXT,249,Integer(ThisUrl));<br> Result:=False;<br> end;<br>end;<br><br>procedure TForm1.WMHOTKEY(var Msg:TMessage);<br>var<br> h:HWND;<br> buffer:array[0..256] of char;<br> temp:String;<br>begin<br> if (Msg.LParamHi=KeyId) and (Msg.LParamLo=control) then<br> begin<br> Msg.Result:=1;<br> h:=GetForegroundWindow;<br> GetClassName(h,buffer,255);<br> if StrPas(buffer)='IEFrame' then<br> begin<br> EnumChildWindows(h,@EnumChildWindowsProc,0);<br> GetWindowText(h,buffer,255);<br> buffer[Pos(' - ',buffer)]:=Char(0);<br> temp:='当前网页的URL是:'+ThisUrl+#13#10+'当前网页Title是:'+buffer;<br> MessageBox(h,PChar(temp),'提示信息',MB_OK)<br> end;<br> end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> ThisUrl:=StrAlloc(250);<br> control:=MOD_CONTROL or MOD_SHIFT ;KeyId:=$43;<br> hotkeyid:=GlobalAddAtom('UserDefineHotKey')-$C000;<br> RegisterHotKey(Handle,hotkeyid,control,KeyId);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> UnregisterHotKey(Handle,hotkeyid);<br> DeleteAtom(hotkeyid);<br>end;<br><br>end.<br>怎么样,给分吧!