Board index » delphi » CursorPos & TPoint

CursorPos & TPoint

TControl has event OnMouseMove.

Occurs when the user moves the mouse pointer while the mouse pointer is over
a control.

type TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState; X, Y:
Integer) of object;
property OnMouseMove: TMouseMoveEvent;

Description

Use the OnMouseMove event handler to respond when the mouse pointer moves
after the control has captured the mouse.

Use the Shift parameter of the OnMouseDown event handler, to determine to
the state of the shift keys and mouse buttons. Shift keys are the Shift,
Ctrl, and Alt keys or shift key-mouse button combinations. X and Y are pixel
coordinates of the new location of the mouse pointer in the client area of
the Sender.

--
Sincerely yours,

Vitaliy Fursov

The best way to find out how to do something is to ask Russian programmers
how to do so on http://www.Soft-Club.com

 

Re:CursorPos & TPoint


Or, you coud use WinAPI function called SetCursorPos.
The thing is, that the TPoint is actualy a record of two X and Y integers.
So all what you've got to do is for ex.: SetCursorPos(0,0) That will put
your mouse in the top left corner.

If you want to see, if the mouse moved, then you place a timer on your form,
every now or then check if the X or the Y changed.
Simple, isn't it?

Re:CursorPos & TPoint


The correct syntax is:

Mouse.CursorPos := Point(100, 150);

If you want to use local coordinates instead use:

Mouse.CursorPos := Form1.ClientToScreen(Point(100, 150));

"D" <n...@email.com> schreef in bericht
news:7gd6bmfschlluv1v2b1dicl3i32hcl8o20lk@abc.com...

Quote
> Hi,

> I've got a button on a form, in the onclick event i want to specify
> the mouse cursor position on the screen. I wanna play with moving the
> mouse around.

> I'm just not sure how to define the procedure and the correct syntax
> for specifying the tpoints.

> The OLH says the tpoint is specified by X & Y, but i'm getting integer
> errors trying to work this out.

> I'm using Mouse.CursorPos(something else goes here?);
> It's the 'something else' part i can't work out.

> Am i looking at the right things to do this?
> How do i define the procedure?
> What do i define the vars as?
> What is the syntax for CursorPos?

> Thanks,
> D

Re:CursorPos & TPoint


Quote
D wrote:
> Hi,

> I've got a button on a form, in the onclick event i want to specify
> the mouse cursor position on the screen. I wanna play with moving the
> mouse around.

> I'm just not sure how to define the procedure and the correct syntax
> for specifying the tpoints.

> The OLH says the tpoint is specified by X & Y, but i'm getting integer
> errors trying to work this out.

> I'm using Mouse.CursorPos(something else goes here?);
> It's the 'something else' part i can't work out.

> Am i looking at the right things to do this?
> How do i define the procedure?
> What do i define the vars as?
> What is the syntax for CursorPos?

What about SetCursorPos?
Depending on how you calculate the position you might need ClientToScreen or
v.v. as well.

Regards,
Udo
--
Please reply to newsgroup. No PMs unless requested.

Other Threads