我想获得netmetting的输入IP地址框的句柄和其右边的连接按钮的句柄。现在我已经由h:=FindWindow(nil,'NetMeeting - 通話なし')获得netmetting的句柄(h为HWND),但是下面我想获得其输入框和按钮的句柄就不能实现。举例如下:
var
  ChildH:HWND;
begin
  ChildH:=FindWindowEx(h,0,'Combobox',nil);//Combobox是我自己获得的不知道对不对
  if (ChildH<>0) then
    showmessage('OK');  SendMessage(childH,WM_SETTEXT,0,Integer(pchar(edit1.Text)));//用edit1中的值传到输入框中,稍后再模拟点击连接事件。
end;
疑问:
1、感觉findwindowEx只能获得第一个子控件的句柄,剩下的都不可以,不知是不是自己理解有误。
2、利用ChildH :=GetWindow(h,GW_HWNDFIRST)和ChildH := GetWindow(ChildH, GW_HWNDNEXT)与GetClassName、GetWindowText结合,显示,好像连我打开的其他窗口也显示了出来,不知是不是自己眼花了,呵呵!
希望大家来捧场,帮我解决这个问题。不胜感激!

解决方案 »

  1.   

    大哥指点下吧。我现在能传值到列表框了,不知是否完美。请指正!
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      h:=FindWindow(nil,'NetMeeting - 通話なし');
      if (h<>0) then
      begin
        EnumChildWindows(h,@EnumChildWndProc,0);
      end;
    end;function  EnumChildWndProc(AhWnd:LongInt;
      AlParam:lParam):boolean;stdcall;
    var
      WndClassName: array[0..254] of Char;
      WndCaption: array[0..254] of Char;
      childh:HWND;
      str:pchar;
    begin
      GetClassName(AhWnd,wndClassName,254);
      GetWindowText(aHwnd,WndCaption,254);  if (Strpas(wndClassName)='ComboBox') then
      begin
          // showmessage(inttostr(aHwnd));
        SendMessage(AhWnd,WM_SETTEXT,0,‘1234));
      end;
      result:=true;
    end;
      

  2.   

    上面的程序我又稍微改了下,可以接受edit一系列的文本框输入了,现在想实现点击连接按钮的操作,在EnumChildWndProc中利用如下代码显示出控件的类和caption
    所显示用代码如下:
    with form1.memo1 do
      begin
        lines.add( string(wndClassName));
        lines.add( string(wndCaption));
        lines.add('-------');
      end;
    显示控件类和caption如下:
    msctls_statusbar32-------
    NMGenWindowClass
    NMSeparator
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMComboBox
    -------
    ComboBox-------
    Edit-------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMBorderWindow
    -------
    NMGenWindowClass
    NMLayeredView
    -------
    NMGenWindowClass
    NMEdgedWindow
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMRemoteVideo
    -------
    NMGenWindowClass
    NMLocalVideo
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMLayeredView
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMEdgedWindow
    -------
    NMGenWindowClass-------
    Button-------
    NMGenWindowClass
    NMTrackbar
    -------
    msctls_trackbar32-------
    NMGenWindowClass
    NMEdgedWindow
    -------
    NMGenWindowClass-------
    Button-------
    NMGenWindowClass
    NMTrackbar
    -------
    msctls_trackbar32-------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass-------
    ATL:0044F538-------
    SysHeader32-------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMToolbar
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    NMGenWindowClass
    NMButton
    -------
    Button
    NMButton
    -------
    但是由于button按钮比较多,怎样才能区分出哪个句柄对应的哪个按钮呢。但是由于button按钮比较多,怎样才能区分出哪个句柄对应的哪个按钮呢。希望高手指正,不要让我自问自答了。关于上面的一系列问题也希望大家提出自己的方法。谢
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
    var
      pt : TPoint;
      vAPP: HWND;
      vName : array[0..255] of char;
     // cl : TWndClass ;
    begin
     if GetCursorPos(pt) then
     begin
       vapp := WindowFromPoint(pt);
       if vAPP <> 0  then
       begin     GetClassName(vAPP,vName,255);
         SendMessage(vAPP,WM_SETTEXT,0,integer(pchar('12343')));
         Memo1.Lines.Append(vName);
       end;
     end;
    end;end. 手頭沒有工具分析了CONF了,你發送TEXT出錯的問題,看我上面的方法
      

  4.   

      GetWindowLong(handl,GWL_Id);  // Retrieves the identifier of the window. 通過這個來判斷是哪一個BUTTON或EDIT;
      

  5.   

    你已經取出Handl就知道是哪個Button或Edit了。
      

  6.   

    它显示出来的classname都是Button ,caption是NMButton,感觉好像是在不同的panel上面,是吗?