去2ccc.com下载个CnFindWnd有源代码的
//查找句柄
procedure TCnFindWnd.FindWndExecute;
var
Pos: TPoint;
Buf: array[0..1024] of Char;
begin
GetCursorPos(Pos);
FDrawHandle := WindowFromPoint(Pos);
FWndHandle := IntToStr(FDrawHandle); //Handle
GetClassName(FDrawHandle, Buf, 1024); //Class
FWndClass := Buf;
SendMessage(FDrawHandle, WM_GETTEXT, 1024, Integer(@Buf)); //Text
FWndCaption := Buf;
GetWindowRect(FDrawHandle, FCurRect); //Rect
FWndRect := Format('(%d,%d)-(%d,%d) %d,%d', [FCurRect.Left, FCurRect.Top,
FCurRect.Right, FCurRect.Bottom, FCurRect.Right-FCurRect.Left,
FCurRect.Bottom-FCurRect.Top]);
CnDrawFocusRect(DrawFocus); //画虚框
end;