我想获得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结合,显示,好像连我打开的其他窗口也显示了出来,不知是不是自己眼花了,呵呵!
希望大家来捧场,帮我解决这个问题。不胜感激!
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结合,显示,好像连我打开的其他窗口也显示了出来,不知是不是自己眼花了,呵呵!
希望大家来捧场,帮我解决这个问题。不胜感激!
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;
所显示用代码如下:
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按钮比较多,怎样才能区分出哪个句柄对应的哪个按钮呢。希望高手指正,不要让我自问自答了。关于上面的一系列问题也希望大家提出自己的方法。谢
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出錯的問題,看我上面的方法