procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var pd:TPoint;
WinCon : TWinControl;
WND : HWND;
cmpComponent:TComponent;
begin
if Msg.message=WM_MOUSEMOVE then
begin
GetCursorPos(pd);
WND := Handle;
repeat
WinCon := FindControl(WND);
WND := ChildWindowFromPoint(WinCon.Handle,WinCon.ScreenToClient(pd));
if (WND = 0) or (not WinCon.Showing) or (not WinCon.CanFocus) then //增加判斷 showing focus
exit;
until (WND = WinCon.Handle) or (WinCon.ControlCount <= 0);
cmpComponent := FindComponent(wincon.Name);
if Assigned(cmpComponent) then
begin
Label1.Caption := cmpComponent.Name;
end;
end;
end;
參考: http://delphi.ktop.com.tw/board.php?cid=168&fid=913&tid=101905
沒有留言:
張貼留言