Title: How to get the active TWinControl under the mouse cursor
function FindControlAtPos: TWinControl;
var
Pt: TPoint;
begin
GetCursorPos(Pt);
Result := FindControl(WindowFromPoint(Pt));
end;
Usage Example:
There's the global proc for the OnMouseUp event.
Note: OnClick keeps working, so you can "add" the OnMouseUp
facility to no cost. }
procedure TForm1.GenericMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
TWC: TWinControl;
begin
TWC := FindControlAtPos;
//what for a class !
Showmessage('Here we are: ' + TWC.ClassName);
//Let it blink...
TWC.Visible := False;
Sleep(150);
TWC.Visible := True;
end;