如何遍历出当前6个名字全为‘Form2’的窗体句柄(45分)

  • 主题发起人 主题发起人 冬月
  • 开始时间 开始时间

冬月

Unregistered / Unconfirmed
GUEST, unregistred user!
如何遍历出当前6个名字全为‘Form2’的窗体句柄
 
var<br>&nbsp; i:Integer;<br>begin<br>&nbsp; for i:=0 to Pred(Application.ComponentCount) do<br>&nbsp; begin<br>&nbsp; &nbsp; if UpperCase(Application.Components.ClassName)='TFORM' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if (pos('Form2',Application.Components.Name)&gt;0) then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; showmessage( ' the handle is in next line');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//(Application.Components as TForm).Handle<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;
 
哪个程序不是我的
 
function EnumWindowsProc(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;<br>var<br>&nbsp; Buffer: Array[0..255] of Char;<br>begin<br>&nbsp; Result:=True;<br><br>&nbsp; with TMemo(lParam) do<br>&nbsp; begin<br>&nbsp; &nbsp; GetWindowText(hWnd,Buffer,255);<br>&nbsp; &nbsp; if StrLIComp(Buffer,'Form2',5)=0 then<br>&nbsp; &nbsp; &nbsp; Lines.Add(StrPas(Buffer)+' &nbsp; &nbsp;Handle: '+InttoStr(hWnd));<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; EnumWindows(@EnumWindowsProc,Integer(Memo1));<br>end;<br>
 
接受答案了.
 
后退
顶部