unit Getspcchildhwd;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;  wincls=class
  public
  childhw:integer;
  function get_childhw(mainhw:integer;childclass:integer):integer;
  function enumchildwindowsproc(hw:integer;clsstr:integer):boolean;stdcall;
  end;
var
  Form1: TForm1;
  mainwin:wincls;
implementation{$R *.dfm}
function wincls.get_childhw(mainhw:integer;childclass:integer):integer;
  begin
  enumchildwindows(mainhw,@wincls.enumchildwindowsproc,childclass);
  result:=childhw;
  end;function wincls.enumchildwindowsproc(hw:integer;clsstr:integer):boolean;stdcall;
var
recallclsname:pchar;
  begin
  getmem(recallclsname,256);
  getclassname(hw,recallclsname,255);
  if recallclsname=pchar(clsstr) then
    begin
    childhw:=hw;
    result:=false;
    end
  else
    result:=true;  freemem(recallclsname);
  end;
procedure TForm1.Button1Click(Sender: TObject);
begin
mainwin:=wincls.Create;
edit2.Text:=inttohex(mainwin.get_childhw(form1.Handle,integer(pchar(edit1.Text))),8);
end;end.请大虾指教

解决方案 »

  1.   

    为什么这样做,是不是用C++用多了
    遍历form用下面的代码即可
      for i:=0 to Screen.FormCount-1 do begin
        ShowMessage(Screen.Forms[i].Caption);
      end;
      

  2.   

    我要的不是这样的遍历
    我要找子窗口啊!!
    我的问题是:
    当我用函数写的时候  Lparm 参数可以从enumchildwindows传到
    eumchildwindowsproc中
    但我要是写在类中  为什么 Lparm  不能从enumchildwindows传到wincls.enumchildwindosproc中啊????
      

  3.   

    找子窗口用FindWindowEx(Parent:HWND;Child:HWND; ClassName, WindowName: PChar)