Mega Code Archive

 
Categories / Delphi / Hardware
 

Is mouse over a windowed control

Title: Is mouse over a windowed control? Question: Sometimes it's useful to know if mouse is over a control, for example to change the color of a button when mouse is over Answer: function IsMouseOverControl(Control: TWinControl): Boolean; var P: TPoint; begin GetCursorPos(P); Result := Assigned(Control) and IsWindow(Control.Handle) and (WindowFromPoint(P) = Control.Handle) end;