Results 1 to 5 of 5

Thread: RESOLVED-Convert Long to Single for the GetCursorPos function

  1. #1

    Thread Starter
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694

    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.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    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:
    1. 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

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694
    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

  5. #5

    Thread Starter
    Fanatic Member alexandros's Avatar
    Join Date
    Oct 2002
    Location
    Milky Way Galaxy
    Posts
    694
    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
  •  



Click Here to Expand Forum to Full Width