문제

This is continue of my previous question -> Draw mouse pointer icon? I want to draw mouse in specific window on the desktop, i already know how to draw the mouse and how to track the movement of the real mouse. But i fail to convert screen coordinates, here is example what i want to do: When the REAL mouse is in the upper left corner 0,0 the DRAWN mouse to be in 0,0 of my specific window, and when the REAL mouse is in the down right corner 1600,900 the DRAWN mouse to be in 700,400 of my specific window.

I will re-explain if someone is not understanding exactly the problem.

Thanks in advance.

도움이 되었습니까?

해결책

You need to scale the mouse position w.r.t your window dimensions.

Let DX and DY be the desktop size. Let WX and WY be your window size. Let (Dmx,Dmy) be the coordinate of the original mouse position w.r.t the desktop. Then the position of your mouse within your window according to your requirement would be (Dmx/DX * WX, Dmy/DY * WY). When coding, please remember to make sure the division happens with floating point numbers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top