怎么知道窗体上的哪个控件获得焦点

2025-05-15 19:23:48
推荐回答(1个)
回答1:

HWND GetFocus(VOID);

The GetFocus function retrieves the handle of the window that has the keyboard focus, if the window is associated with the calling thread 's message queue.

测试代码:
var
FocusHandle : THandle;
Buffer : Array [0..255] of Char;
begin
FocusHandle := GetFocus;

GetClassName ( FocusHandle, Buffer, 256 );

ShowMessage ( Buffer );
end;