|
-
Apr 2nd, 2003, 08:54 AM
#1
Thread Starter
Fanatic Member
RESOLVED-Convert Long to Single for the GetCursorPos function
Hello
i am using the getcursorpos function to get the correct position
of the mouse.
the problem is it does not seem to show correct position.
the getcursorpos returns a POINTAPI type which has a X as long and Y as long.
I want the X,Y to get converted to Single.
i tried form1.scalex(point.x,vblong,vbsingle)
but it did not work.
instead i used xsingle=15*xlong and it seems to quite work but not 100%.
also how to i convert from twips to single ??
thanks !!
Last edited by alexandros; Apr 2nd, 2003 at 09:54 AM.
-
Apr 2nd, 2003, 09:01 AM
#2
Well, first, GetCursorPos works relative to the screen, so that will throw off your values if you expect it to be relative to your window. Second, you convert the values from pixels to twips using ScaleX/ScaleY
VB Code:
Msgbox ScaleX(pt.X, vbPixels, ScaleMode)
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 2nd, 2003, 09:04 AM
#3
-
Apr 2nd, 2003, 09:19 AM
#4
Thread Starter
Fanatic Member
well i got a ruler control .
it has a function like that
I want to set X,Y which are of long type (POINTAPI) to single
Public Sub RenderTrackLine(X As Single, Y As Single)
If mvarMouseTrackingOn = True Then
RenderControl
'Optionaly render Mouse tracking line
Select Case Orientation
Case orHorizontal
Line (X, 0)-(X, ScaleHeight)
Case orVertical
Line (0, Y)-(ScaleWidth, Y)
End Select
End If
End Sub
when i try to just make
GetcursorPos Point
ruler.rendertrackline point.x,point.y
it fails
i also tried to do this but it said 'Type Mismatch'
GetCursorPos point
kx = point.X
ky = point.Y
webbrowser.ClientToWindow kx, ky
-
Apr 2nd, 2003, 09:53 AM
#5
Thread Starter
Fanatic Member
thanks guys ! i solved it
Public Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Dim point As POINTAPI
GetCursorPos point
Call ScreenToClient(Form1.hwnd, point)
kx = point.X
ky = point.Y
ruler_horiz.RenderTrackLine ScaleX(kx, vbPixels, vbTwips) - wbrowser.Left, ScaleY(ky, vbPixels, vbTwips) - wbrowser.TOp
ruler_verti.RenderTrackLine ScaleX(kx, vbPixels, vbTwips) - wbrowser.Left, ScaleY(ky, vbPixels, vbTwips) - wbrowser.TOp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|