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 ?
Printable View
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 ?
VB 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 Label1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = 2 Then Dim udtPos As POINTAPI GetCursorPos udtPos With Form2 .Left = udtPos.x * Screen.TwipsPerPixelX .Top = udtPos.y * Screen.TwipsPerPixelY .Show End With End If End Sub
that's beautiful ! thank you