New Tip - ...get the active TWinControl under the mouse cursor ?

  • From: "SwissDelphiCenter.ch" <newsletter@xxxxxxxxxxxxxxxxxxxx>
  • To: sdcnewtip@xxxxxxxxxxxxx
  • Date: Thu, 28 Feb 2002 12:54:39 +0100

* SwissDelphiCenter new Tip newsletter
* www.swissdelphicenter.ch
*
* To unsubscribe send a mail to sdcnewtip-request@xxxxxxxxxxxxx with the
* subject unsubscribe


Hallo,

Folgender neuer Tip ist neu auf SwissDelphiCenter verfügbar:

Besuchen Sie die Programmier Tips unter 
http://www.swissdelphicenter.ch/de/tipsindex.php


Bewerten Sie diesen Tip nach Schwierigkeitsgrad, Nützlichkeit und Gesamthaft auf
http://www.swissdelphicenter.ch/de/showcode.php?id=1034



Autor:
Loïs Bégué <delphi@xxxxxxxx>
http://www.begue.de


-------------
...das aktive TWinControl unter der Maus herausfinden ?
-------------
Kategorie: Oberfläche



{ Sie können z.B diese Funktion in einer allgemein gültigen
  Prozedure aufrufen, die Sie dann allen betroffenen Ereignisse
  zuweisen. }

{ You may call this function in a global event procedure,
  linking as many components events to it as you need. }

function FindControlAtPos: TWinControl;
var
  Pt: TPoint;
begin
  GetCursorPos(Pt);
  Result := FindControl(WindowFromPoint(Pt));
end;


{ (Beispiel) Hier die allgemein gültige Procedure für OnMouseUp.
  Die Behandlung von OnClick bleibt dabei erhalten:
  die Funktionalität aus OnMouseUp kommt dazu. }

{ (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;




Best Regards
SwissDelphiCenter Team
www.swissdelphicenter.ch
[automatisch generierte EMail]


----------------------------------------------------
ENGLISH NEWSLETTER
----------------------------------------------------

Hi,

This new tip is new available on SwissDelphiCenter.ch:

Visit the programming tips at http://www.swissdelphicenter.ch/en/tipsindex.php


Rate this tip after skill, useful and overall at
http://www.swissdelphicenter.ch/en/showcode.php?id=1034



Author:
Loïs Bégué <delphi@xxxxxxxx>
http://www.begue.de


-------------
...get the active TWinControl under the mouse cursor ?
-------------
Category: Forms



{ Sie können z.B diese Funktion in einer allgemein gültigen
  Prozedure aufrufen, die Sie dann allen betroffenen Ereignisse
  zuweisen. }

{ You may call this function in a global event procedure,
  linking as many components events to it as you need. }

function FindControlAtPos: TWinControl;
var
  Pt: TPoint;
begin
  GetCursorPos(Pt);
  Result := FindControl(WindowFromPoint(Pt));
end;


{ (Beispiel) Hier die allgemein gültige Procedure für OnMouseUp.
  Die Behandlung von OnClick bleibt dabei erhalten:
  die Funktionalität aus OnMouseUp kommt dazu. }

{ (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;



Best Regards
SwissDelphiCenter Team
www.swissdelphicenter.ch
[automatic generated EMail]

Other related posts:

  • » New Tip - ...get the active TWinControl under the mouse cursor ?