Results 1 to 3 of 3

Thread: position second form at mouse cursor coordinates

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Resolved position second form at mouse cursor coordinates

    I have a label on my first form.

    When I right click on this label, i want a second form to open at the mouse coordinates of where I just right-clicked. So the left/top properties of the second form are right at the mouse cursor.

    how can i do this ?
    Last edited by ZeBula8; Sep 22nd, 2006 at 11:52 AM. Reason: resolved

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: position second form at mouse cursor coordinates

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type POINTAPI
    4.         x As Long
    5.         y As Long
    6. End Type
    7.  
    8. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    9.  
    10. Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    11. If Button = 2 Then
    12.    
    13.     Dim udtPos As POINTAPI
    14.    
    15.     GetCursorPos udtPos
    16.    
    17.     With Form2
    18.         .Left = udtPos.x * Screen.TwipsPerPixelX
    19.         .Top = udtPos.y * Screen.TwipsPerPixelY
    20.         .Show
    21.     End With
    22.  
    23. End If
    24. End Sub

  3. #3

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: position second form at mouse cursor coordinates

    that's beautiful ! thank you

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