EnumChildWindows(100)

  • 主题发起人 主题发起人 rqj
  • 开始时间 开始时间
R

rqj

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.newBar1Click(Sender: TObject);var h:HWND; ThreadID:THandle; buffer:array[0..255] of char;begin h:= FindWindow(nil,pchar(Fcontrol.FromName)); if h<>0 then Begin EnumChildWindows(h,@EnumChildWindowsProc,Longint(@buffer[0]));// ShowMessage(StrPas(buffer)); End Else Begin ShowMessage('窗体'+Fcontrol.FromName+'句柄没有找到!'); Exit; End;end;function EnumChildWindowsProc(hwnd,lparam:Integer):Boolean;var WndCaption: array[0..255] of Char; ulpClassName : array[0..255] of Char; i : integer ;begin Result:=True; windows.GetWindowText(hwnd, WndCaption, 256); windows.GetClassName(hwnd, ulpClassName, 256); //if (WndCaption[0]<>chr(0)) then begin showmessage(StrPas(WndCaption)+':'+StrPas(ulpClassName)); //如果ulpClassName是'TEdit'(Delphi/BCB程序)或'Edit'(VC/VB程序)则用FindWindowEx找到控件句柄 end;end;为什么我取道的值都是空的呢 showmessage(StrPas(WndCaption)+':'+StrPas(ulpClassName)); 为空
 
那么麻烦干嘛 楼主看看这段代码procedure TForm1.Timer1Timer(Sender: TObject);varPos: TPoint;Handle: HWND;Buf: array[0..1024] of Char;beginGetCursorPos(Pos);Handle := WindowFromPoint(Pos);HandleEdit.Text := IntToStr(Handle);GetClassName(Handle, Buf, 1024);ClassEdit.Text := Buf;SendMessage(Handle, WM_GETTEXT, 1024, Integer(@Buf));TextEdit.Text := Buf;end;
 
function EnumChildWindowsProc(hwnd,lparam:Integer):Boolean;[red]stdcall;[/red]var WndCaption: array[0..255] of Char; ulpClassName : array[0..255] of Char; i : integer ;begin Result:=True; windows.GetWindowText(hwnd, WndCaption, 256); windows.GetClassName(hwnd, ulpClassName, 256); //if (WndCaption[0]<>chr(0)) then begin showmessage(StrPas(WndCaption)+':'+StrPas(ulpClassName)); //如果ulpClassName是'TEdit'(Delphi/BCB程序)或'Edit'(VC/VB程序)则用FindWindowEx找到控件句柄 end;end;function EnumChildWindowsProc(hwnd,lparam:Integer):Boolean;[red]stdcall;[/red]windows的回调函数默认使用stdcall传递
 
后退
顶部