Results 1 to 3 of 3

Thread: Form StartupPosition at mouse?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    MN
    Posts
    362

    Form StartupPosition at mouse?

    Is there a way to have a new form open where the mouse pointer is located?

    Name:  Clipboard01.jpg
Views: 232
Size:  8.3 KB


    So if a user clicks on the button to open a new form, the new form opens where the user clicked....

  2. #2
    gibra
    Guest

    Re: Form StartupPosition at mouse?

    You can calculate it, related to screen; i.e.
    Code:
        Form2.Move Form1.Left + Command1.Left + Command1.Width, Form1.Top + Command1.Top + Command1.Height
        Form2.Show , Me

  3. #3
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,000

    Re: Form StartupPosition at mouse?

    Code:
    Private Type POINTAPI
        x As Long
        y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Private Sub Form_Load()
        Dim iM As POINTAPI
        
        GetCursorPos iM
        Me.Move iM.x * Screen.TwipsPerPixelX, iM.y * Screen.TwipsPerPixelY
    End Sub

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