again.. i got 2 forms hehe
when right clicking one
second one appears
how do i make it so that when second one apears
it will appear at the place where mouse was clicked?
(in other words, how do i capture mouse positions..)
Printable View
again.. i got 2 forms hehe
when right clicking one
second one appears
how do i make it so that when second one apears
it will appear at the place where mouse was clicked?
(in other words, how do i capture mouse positions..)
Code:Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Dim mypt As POINTAPI
GetCursorPos mypt
MsgBox "Cursor at: " & mypt.x & ", " & mypt.y
End Sub
i tried that.. but that doesnt display form2 where the mouse was clickedCode:Private Sub Form_Mouseup(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
Form2.Show
Dim MousePosition As POINTAPI
GetCursorPos MousePosition
Form2.Move Form1.Left + MousePosition.x, Form1.Top + MousePosition.y
End If
End Sub
any times? (first time playing around with move and cursor stuff)
Try this:
The windows API returns all positions/sizes/etc in pixels. VB works in Twips.Code:Private Sub Form_Mouseup(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
Form2.Show
Dim MousePosition As POINTAPI
GetCursorPos MousePosition
Form2.Move Form1.Left + (MousePosition.x * Screen.TwipsPerPixelX), Form1.Top + (MousePosition.y * Screen.TwipsPerPixelY)
End If
End Sub
thanks parksie
just had to modify it a little bit
greatly appreciated..Code:If Button = 2 Then
Form2.Show
Dim MousePosition As POINTAPI
GetCursorPos MousePosition
Form2.Move (MousePosition.x * Screen.TwipsPerPixelX), (MousePosition.y * Screen.TwipsPerPixelY)
EnableTrap Form2
End If