|
-
Aug 24th, 2000, 01:47 PM
#1
Thread Starter
Frenzied Member
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..)
-
Aug 24th, 2000, 01:52 PM
#2
Monday Morning Lunatic
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 refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 24th, 2000, 02:02 PM
#3
Thread Starter
Frenzied Member
hmm
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, Form1.Top + MousePosition.y
End If
End Sub
i tried that.. but that doesnt display form2 where the mouse was clicked
any times? (first time playing around with move and cursor stuff)
-
Aug 24th, 2000, 02:05 PM
#4
Monday Morning Lunatic
Try this:
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
The windows API returns all positions/sizes/etc in pixels. VB works in Twips.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 24th, 2000, 02:16 PM
#5
Thread Starter
Frenzied Member
here we go..
thanks parksie
just had to modify it a little bit
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
greatly appreciated..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|