Results 1 to 3 of 3

Thread: [RESOLVED] window position

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    95

    Resolved [RESOLVED] window position

    I want to popup a window at the users mouse cursor thats over a control window, only that x/y position of that control isn't accurate by itself,and when the form is changed that position is the same which throws things off,so how can I get it relative to the entire desktop so I have an accurate position?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: window position

    If I understood you correctly GetCursorPos api function should do the trick:
    Code:
    Option Explicit
    
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Private Sub Form_Click()
    Dim pt As POINTAPI
    
        GetCursorPos pt
        Load Form2
        Form2.Move pt.X * Screen.TwipsPerPixelX, pt.Y * Screen.TwipsPerPixelY
        Form2.Show
    
    End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    95

    Re: [RESOLVED] window position

    thankyou kind sir, that did the trick

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