读书人

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

发布时间: 2012-03-12 12:45:33 作者: rapoo

如何知道窗体上的哪个控件获得焦点?
如题,有不用循环的吗?

[解决办法]
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;
[解决办法]
var
s:string;
begin
s:=Activecontrol.Name;
ShowMessage(s);
end;
[解决办法]
Activecontrol
[解决办法]
Activecontrol

读书人网 >.NET

热点推荐