Making a window appear at the mouse

But I want the bottom-right hand corner to appear at the mouse popint.

How would I do this



Answer this question

Making a window appear at the mouse

  • Tej51078

    Dave: The form doesn't appear (Yes, I _have_ included the F.Show())

    Richard: Thanks, it works!

    Thank you all for your time.


  • Zjivago

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    Dim F As New Form2
    F.StartPosition = FormStartPosition.Manual
    F.Left = Cursor.Position.X - F.Width
    F.Top = Cursor.Position.Y - F.Height
    F.Show()
    End Sub

  • Lisa Shipley

    Ok .. is this what you were after

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim pt As Point = Windows.Forms.Cursor.Position

    Dim size As Size = Me.Size

    Me.Location = New Point(pt.X - size.Width, pt.Y - size.Height)

    End Sub

    Richard


  • Kaleb

    It works for me.

    What particular aspect "doesn't work"


  • sfjari

    Can you advise if the form you want to show is an mdi child form, or a top level form

    Thanks

    Richard


  • pimmy21

    Dave: doesn't work, but thanks for your time.

    Dick: It's a top level form.


  • Making a window appear at the mouse