Example

The following code creates and displays a label when a mouse button is
pressed. If you attach this event handler to the OnMouseDown event of a
form, a label specifying the coordinates of the mouse pointer appears when
the user clicks the mouse button. Note that the StdCtrls unit must be added
to the uses clause of the interface section of the form's unit to be able to
create labels dynamically.

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  NewLabel: TLabel;
begin
  NewLabel := TLabel.Create(Form1);
  NewLabel.Parent := Self;
  NewLabel.Left := X;
  NewLabel.Top := Y;
  NewLabel.Caption := '(' + IntToStr(X) + ',' + IntToStr(Y) + ')';
  NewLabel.Visible := True;
end;

Regards
Graham
----- Original Message -----
From: "Chrissy R" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Sunday, February 18, 2001 8:43 PM
Subject: Re: [DUG]: Mouse Position


> Where I want the code does not have to mouse position
> but there is a command (property or method) that can
> give it to me and that is what I am looking for.
>
> Chrissy.
>
>
> ----- Original Message -----
>
> > Try the OnMouseMove event.
> >
> > ----- Original Message -----
> >
> > > How do I get the position of the mouse in a control, a form say?
> > > I know I have done the before but cannot remember the command.
> > >
>
>
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to