F forever_ao Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-26 #1 如题。如何捕获激活窗体的句柄呢?<br>谢谢
Y ysai Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-26 #2 如果是系统的窗体:<br>GetActiveWindow<br>如果是自己程序的<br>Screen.ActiveForm.Handle
李 李张柏芝 Unregistered / Unconfirmed GUEST, unregistred user! 2004-03-13 #7 //新建app,放memo1,button1.[]<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hCurrentWindow: HWnd;<br> szText: array[0..254] of char;<br>begin<br> hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);<br> while hCurrentWindow <> 0 do<br> begin<br> if iswindowvisible(hCurrentWindow) then<br> begin<br> if GetWindowText(hCurrentWindow, @szText, 255)>0 then<br> memo1.Lines.Add(StrPas(@szText));<br> end;<br> hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);<br> end;<br>end;<br><br>end.<br>
//新建app,放memo1,button1.[]<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hCurrentWindow: HWnd;<br> szText: array[0..254] of char;<br>begin<br> hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);<br> while hCurrentWindow <> 0 do<br> begin<br> if iswindowvisible(hCurrentWindow) then<br> begin<br> if GetWindowText(hCurrentWindow, @szText, 255)>0 then<br> memo1.Lines.Add(StrPas(@szText));<br> end;<br> hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);<br> end;<br>end;<br><br>end.<br>