|
-
Oct 18th, 2002, 08:28 AM
#1
Thread Starter
New Member
Position Form Using Mouse Coordinates
hi guyz,
when the user clicks a label on a form, i wish to load a new form and position the new form such that the new form's top-left hand corner is at the mouse's coordinates.
i know how to use GetCursorPos to get the mouse coordinates but after that i'm lost.
thanks for your help guyz...
Rommel the iCeMAn,
Computer Programmer,
Barbados, Caribbean.
-
Oct 18th, 2002, 08:40 AM
#2
I wonder how many charact
VB Code:
Form2.Left = returnedMousePositionX
Form2.Top = returnedMousePositionY
API usually returns in pixels, VB defaults to twips...
So you may have to:
VB Code:
Form2.Left = Screen.TwipsPerPixelX * returnedMousePositionX
Form2.Top = Screen.TwipsPerPIxelY * returnedMousePositionY
where returnedMousePositionX , Y are the mouse coordinates...
-
Oct 18th, 2002, 08:41 AM
#3
Frenzied Member
This will explain it a little more clearly than nemaroller.
VB 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 Command1_Click()
Dim NewFrm1 As New Form1 '<- copy the current form
Dim CursorPos As POINTAPI '<- the form pos will be here
GetCursorPos CursorPos '<- Sets CursorPos
CursorPos.y = CursorPos.y * Screen.TwipsPerPixelY
CursorPos.x = CursorPos.x * Screen.TwipsPerPixelX
'^ converts pixels to twips ^
NewFrm1.Top = CursorPos.y '<- Sets NewFrm1's top pos
NewFrm1.Left = CursorPos.x '<- Sets NewFrm1's left pos
NewFrm1.Show '<- Displays your new form!
End Sub
-
Oct 18th, 2002, 08:44 AM
#4
I wonder how many charact
Christ Macai, how'd you know what I was going to post?
-
Oct 18th, 2002, 08:46 AM
#5
Frenzied Member
Originally posted by nemaroller
Christ Macai, how'd you know what I was going to post?
It becomes common knowledge amongst VBers... im just faster
than you.
-
Oct 18th, 2002, 11:01 AM
#6
Thread Starter
New Member
hehehehe ...
thanks guyz ... i do some fairly advanced database programming, sometimes i even crossover from VB to Linux DBs .. yet the small stuff like this often eludes me!
thanks again...
Rommel the iCeMAn,
Computer Programmer,
Barbados, Caribbean.
-
Oct 18th, 2002, 11:03 AM
#7
Frenzied Member
Im good at alot of stuff. But im weird with DBs! I wrote my own
DB format, but i just cant get the hang on Access or SQL!!
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
|