开发者

c++ mouseover event

开发者 https://www.devze.com 2023-01-11 22:23 出处:网络
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.

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? 开发者_JAVA百科 sorry if what i said is confusing i couldn't explain it better.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消