pnhuan
August 2nd, 2001, 09:12 PM
My problem is that:
I want to get the current position of the Mouse in my program window. What I do
now is to get its position in the screen using get current mouse position
function:
Type POINTAPI
x as Long
y as Long
End Type
Declare Sub SetCursorPos Lib "User32" (byval x%, byval y%)
Declare Sub GetCursorPos Lib "User32" (lpoint as POINTAPI)
This returns the values of current cursor position in the screen in Pixel unit.
And I have to convert it in Twips unit, which is used in my program window, so
that I can draw something in the current position. And what I did is
GetCursorPos mousePos
CurrentX = mousePos.x * XFactor - frmMain.Left
CurrentY = mousePos.y * YFactor - frmMain.Top
where currentX and CurrentY are the position of the cursor in my program window.
The trouble is that, the position used for drawing is not that value (relatively
from TOP-LEFT of the window), but it is relatively from the top-left of the
DRAWABLE PART of the window. In this case, it does not include the manu bar. I
do not have a handle for the Drawable part of the window to get top-left
position of that as an off-set value. What I think I can do is somehow to get
the Height of the Manu bar so that I can get the top-left position of the
drawable part of the window.
Do anyone has any idea how to fix that, or any cleaner way to do the job (draw
something at the current postion of the cursor). It sounds straight forward ,
does not it.
Any help will be very appreciated
I want to get the current position of the Mouse in my program window. What I do
now is to get its position in the screen using get current mouse position
function:
Type POINTAPI
x as Long
y as Long
End Type
Declare Sub SetCursorPos Lib "User32" (byval x%, byval y%)
Declare Sub GetCursorPos Lib "User32" (lpoint as POINTAPI)
This returns the values of current cursor position in the screen in Pixel unit.
And I have to convert it in Twips unit, which is used in my program window, so
that I can draw something in the current position. And what I did is
GetCursorPos mousePos
CurrentX = mousePos.x * XFactor - frmMain.Left
CurrentY = mousePos.y * YFactor - frmMain.Top
where currentX and CurrentY are the position of the cursor in my program window.
The trouble is that, the position used for drawing is not that value (relatively
from TOP-LEFT of the window), but it is relatively from the top-left of the
DRAWABLE PART of the window. In this case, it does not include the manu bar. I
do not have a handle for the Drawable part of the window to get top-left
position of that as an off-set value. What I think I can do is somehow to get
the Height of the Manu bar so that I can get the top-left position of the
drawable part of the window.
Do anyone has any idea how to fix that, or any cleaner way to do the job (draw
something at the current postion of the cursor). It sounds straight forward ,
does not it.
Any help will be very appreciated