views:

49

answers:

1

ok s it is really easy to create mouse over event if the object is NOT moving. but the problem that the object gonna be moving every 50 millisecond. it is not a string line so i can create a script it is a circle. i used to use getcursorpos(). than get the object x and y. the other problem is this

 p  X---------------------

 y 
 |
 |     
 |
 |       cursor
 |
 |
 |

where it says p that is the position ill get for the x and y. where is the cursor in the middle if ill get the position of the cursor and compare it to the x and y they won't match. plus the object keeps moving so it is harder to track. any idea? sorry if what i said is confusing i couldn't explain it better.

+2  A: 

If you follow the GetCursorPos documentation it say:

A pointer to a POINT structure that receives the screen coordinates of the cursor

But when you draw you have to provide client coordinates. Is this is the issue you will need to transform from screen coordinates to client coordinates with the function aptly named ScreenToClient.

But instead of tracking the cursor position by hand I suggest to use the WM_MOUSEMOVE event, which already provides you with the client coordinates.

Ismael
+1 for the screen/client coordinates. but more thing need to be added if the mouse remain static and eclipse was moved onto the mouse.
YeenFei
i couldn't find that many details for the event
Ramiz Toma
@YeenFei you can use WM_MOUSEMOVE to track where the last position of the mouse is, and then use WM_TIMER to move the circle, you can add a check for the last cursor position is close the the circle. Windows uses an event based programming model, you have to design your programs in term of those events provided by the system (mouse move, mouse click, timer firing, button click, etc, etc).
Ismael
your answer is not really helpfull you didn't give me detials.can you give me more detials
Ramiz Toma
If you read the documentation I've pointed you will see at the bottom a link to a sample application which does much of what you are looking for, here is the link in the case you have missed it http://msdn.microsoft.com/en-us/library/ms648380%28v=VS.85%29.aspx#_win32_Using_the_Keyboard_to_Move_the_Cursor.
Ismael