Results 1 to 3 of 3

Thread: Display form at cursor position

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Display form at cursor position

    I am trying to use a windows form as a custom contextmenu which is fine as I have done a form with translucent background colour. However the problem is that I am having problems displaying the form at my cursor position. I have a mdi chaild form in my app and when I right click I want to display my custom contextmenu form at the point where I right click in the mdichild form. The only other thing is that I want the middle of the form to be displayed at the cursor point.

    Thanks

    Simon

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Display form at cursor position

    try this:

    vb Code:
    1. Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    2.     Dim p As Point = Cursor.Position
    3.     p.Offset(-Form2.Width \ 2, -Form2.Height \ 2)
    4.     Form2.Location = p
    5.     Form2.Show()
    6. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    170

    Re: Display form at cursor position

    Paul,

    Thanks for you help, worked perfectly

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