Board index » cppbuilder » Getting Mouse coordinates

Getting Mouse coordinates


2005-10-26 03:01:30 PM
cppbuilder80
Hello,
Maby this is a stupid question, but how do I retrieve the actual mouse
position coordinates from my Form?
Do I have to place some mouse component on it?
Thanks
Henk
 
 

Re:Getting Mouse coordinates

A single reply...
GREAT!!!!
thanks
"Alexander Aliev" < XXXX@XXXXX.COM >schreef in bericht
Quote
Hi,

>...how do I retrieve the actual mouse
>position coordinates from my Form?
>
>Do I have to place some mouse component on it?

You may use global variable Mouse and get screen
coordinates of a cursor. For example:

int XX = Mouse->CursorPos.x;
int YY = Mouse->CursorPos.y;

You don't need any component for this.

Bye,
Alexander


 

Re:Getting Mouse coordinates

Hi,
Quote
...how do I retrieve the actual mouse
position coordinates from my Form?

Do I have to place some mouse component on it?
You may use global variable Mouse and get screen
coordinates of a cursor. For example:
int XX = Mouse->CursorPos.x;
int YY = Mouse->CursorPos.y;
You don't need any component for this.
Bye,
Alexander
 

{smallsort}

Re:Getting Mouse coordinates

I see that mouse coords are according display-size settings.
Is it possible to retrieve the actual screensize (like 1280 * 1024 or so) ?
thanks
Henk
"Alexander Aliev" < XXXX@XXXXX.COM >schreef in bericht
Quote
Hi,

>...how do I retrieve the actual mouse
>position coordinates from my Form?
>
>Do I have to place some mouse component on it?

You may use global variable Mouse and get screen
coordinates of a cursor. For example:

int XX = Mouse->CursorPos.x;
int YY = Mouse->CursorPos.y;

You don't need any component for this.

Bye,
Alexander


 

Re:Getting Mouse coordinates

I will answer myself...
I found the 'Screen' variable like the 'Mouse' one!
;-)
"Henk van Winkoop" < XXXX@XXXXX.COM >schreef in bericht
Quote
I see that mouse coords are according display-size settings.

Is it possible to retrieve the actual screensize (like 1280 * 1024 or so)
?

thanks

Henk



"Alexander Aliev" < XXXX@XXXXX.COM >schreef in bericht
news: XXXX@XXXXX.COM ...
>Hi,
>
>>...how do I retrieve the actual mouse
>>position coordinates from my Form?
>>
>>Do I have to place some mouse component on it?
>
>You may use global variable Mouse and get screen
>coordinates of a cursor. For example:
>
>int XX = Mouse->CursorPos.x;
>int YY = Mouse->CursorPos.y;
>
>You don't need any component for this.
>
>Bye,
>Alexander
>
>


 

Re:Getting Mouse coordinates

"Henk van Winkoop" < XXXX@XXXXX.COM >wrote:
Quote

I found the 'Screen' variable like the 'Mouse' one!
Save yourself some work. Use the win32 API GetCursorPos
and then translate the mouse position from screen relative
point to a control relative point using ScreenToClient. For
example:
TPoint P;
::GetCursorPos( &P );
P = ScreenToClient( P );
Mouse->CursorPos may be the same (I hope it is) but IIRC, when
I used it with:
Application->ActivateHint( Mouse->CursorPos );
the hint displayed at the tail of the mouse instead of the hot
spot. Perhaps that's a feature of the hint but I know that the
above works correctly.
~ JD
 

Re:Getting Mouse coordinates

GREAT!
"JD" < XXXX@XXXXX.COM >schreef in bericht
Quote

"Henk van Winkoop" < XXXX@XXXXX.COM >wrote:
>
>I found the 'Screen' variable like the 'Mouse' one!

Save yourself some work. Use the win32 API GetCursorPos
and then translate the mouse position from screen relative
point to a control relative point using ScreenToClient. For
example:

TPoint P;
::GetCursorPos( &P );
P = ScreenToClient( P );

Mouse->CursorPos may be the same (I hope it is) but IIRC, when
I used it with:

Application->ActivateHint( Mouse->CursorPos );

the hint displayed at the tail of the mouse instead of the hot
spot. Perhaps that's a feature of the hint but I know that the
above works correctly.

~ JD