• Advertisement

Archived

This topic is now archived and is closed to further replies.

getting the mouse position

This topic is 6513 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway to get the current position of the mouse in windows without having to process a WM_MOUSEMOVE or similar message? I''ve tried the docs, but I can''t find anything that''d help. Thanks, - Daniel
my homepage

Share this post


Link to post
Share on other sites
Advertisement
I don''t know a windows API command to get the mouse position, but why do you need it? It''s enough if you save the mouse position in a variable every time when WM_MOUSEMOVE occurs.

Visit our homepage: www.rarebyte.de.st

GA

Share this post


Link to post
Share on other sites
I have a scrolling map and I want to know when the user has put the mouse against the edge of the screen so that it can scroll. If I just process WM_MOUSEMOVE the user has to move the mouse up and down or whatever to get it to scroll.

- Daniel
my homepage

Share this post


Link to post
Share on other sites
BOOL GetCursorPos(
LPPOINT lpPoint // cursor position
);

lpPoint
[out] Pointer to a POINT structure that receives the screen coordinates of the cursor.

so to use it...

POINT pt;
GetCursorPos(&pt);

This will give you screen cords however. So if you need window cords just use ScreenToClient.

Josh

Share this post


Link to post
Share on other sites
You could also solve this problem with WM_MOUSEMOVE and storing the coordinates....
but use GetCursorPos() if it''s there

Visit our homepage: www.rarebyte.de.st

GA

Share this post


Link to post
Share on other sites
Does anyone know how to do the same thing in Visual Basic?

Its not for a game but for a business application.

Share this post


Link to post
Share on other sites
If you use GetCursorPos, make sure to subtract the window top & left coordinates. That way if the user moves the window(non full screen), you account for it!

Share this post


Link to post
Share on other sites
EB, Yes, you can do the same thing in VB... Just declare GetCursorPos() [btw, there''s also SetCursorPos()] as an function from the Win32 API, and then call it from your proggy... that''s about it... if you need more info lemme know...

..-=gLaDiAtOr=-..

Share this post


Link to post
Share on other sites
Gladiator

yeah thats the problem. I understand c very well, and understand what I''m supposed to be doing, I just don''t know the sentax to do it in VB. In particular its the passing the whatever to the function. In c you pass the lpPoint which is a structure. If you could explain that I would be extremely grateful.... like for example... I thought passing a variant would suffice but vb then returns saying it can''t use the information. I also tryed a plain old object, but that didn''t work either.

Share this post


Link to post
Share on other sites

  • Advertisement