procedure TForm1.GetMousePosHwndAndClassName(Sender: TPoint);
var
hWnd: THandle;
aName: array[0..255] of char;
TempText: string;
begin
hWnd := WindowFromPoint(Sender);
Label1.Caption := 'Handle : ' + IntToStr(hWnd);
if boolean(GetClassName(hWnd, aName, 256)) then
lbNumber.Caption := 'ClassName : ' + string(aName)
else
lbNumber.Caption := 'ClassName : not found';
if hWnd <> 0 then
begin
SetLength(TempText, 21);
SendMessage(hWnd, WM_GETTEXT, 20, Integer(PChar(TempText)));
Label2.Caption := TempText;
end;
end;
这样我可以获取窗体上的所有DELPHI控件的字符,但不能获取一个ActiveX控件里的字符,大家帮帮忙呀。