首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

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

2012-03-12 
如何知道窗体上的哪个控件获得焦点?如题,有不用循环的吗?[解决办法]HWND GetFocus(VOID)The GetFocus fun

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

[解决办法]
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

热点排行