MouseDown event prevents a form from being moved

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    MouseDown event prevents a form from being moved

    Hi

    I've discovered a bizarre Windows Forms (VB.NET) behavior that is
    resulting in a Form not being able to be moved. To reproduce this:

    1) Create yourself a new Windows Application in Visual Studio 2005.
    2) A project will be created with one Form (Form 1). Don't add any
    code to the project.
    3) Run the project and confirm that Form 1 is displayed and you can
    drag the Form around your screen by clicking and dragging the Form's
    title bar, ie; standard Windows application behaviour.
    4) Now add the following code to Form 1:

    Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As
    System.Windows. Forms.MouseEven tArgs) Handles Me.MouseDown

    Beep()

    End Sub

    5) Now run the project again.

    You will find that
    a) If you click the empty client area of the Form your PC will beep as
    you would expect.
    b) If you click Form 1's Title Bar or attempt to drag the Form the
    application will lock and you can't access the Minimise, Maximise or
    Close buttons on the Title Bar. The Form seems to lock for about 30 -
    45 secs on my PC.

    I discovered this issue in my main project and can't resolve it. It
    seems that as soon as you declare a MouseDown event handler this
    problem will arise.

    Anyone got any ideas about why this happening?

    Peter,
  • Chris Dunaway

    #2
    Re: MouseDown event prevents a form from being moved

    On Sep 22, 10:11 pm, Peter <pete...@circ le-consulting.co.n zwrote:
    Hi
    >
    I've discovered a bizarre Windows Forms (VB.NET) behavior that is
    resulting in a Form not being able to be moved. To reproduce this:
    >
    1) Create yourself a new Windows Application in Visual Studio 2005.
    2) A project will be created with one Form (Form 1). Don't add any
    code to the project.
    3) Run the project and confirm that Form 1 is displayed and you can
    drag the Form around your screen by clicking and dragging the Form's
    title bar, ie; standard Windows application behaviour.
    4) Now add the following code to Form 1:
    >
    Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As
    System.Windows. Forms.MouseEven tArgs) Handles Me.MouseDown
    >
    Beep()
    >
    End Sub
    >
    5) Now run the project again.
    >
    You will find that
    a) If you click the empty client area of the Form your PC will beep as
    you would expect.
    b) If you click Form 1's Title Bar or attempt to drag the Form the
    application will lock and you can't access the Minimise, Maximise or
    Close buttons on the Title Bar. The Form seems to lock for about 30 -
    45 secs on my PC.
    >
    I discovered this issue in my main project and can't resolve it. It
    seems that as soon as you declare a MouseDown event handler this
    problem will arise.
    >
    Anyone got any ideas about why this happening?
    >
    Peter,
    I cannot duplicate the problem. I was able to move the app by
    dragging the title bar as well as click the client area to hear the
    beep.

    Microsoft Visual Studio 2005
    Version 8.0.50727.762 (SP.050727-7600)
    Microsoft .NET Framework
    Version 2.0.50727 SP2

    Installed Edition: Professional

    Chris

    Comment

    • Peter

      #3
      Re: MouseDown event prevents a form from being moved

      On Sep 24, 1:26 am, Chris Dunaway <dunaw...@gmail .comwrote:
      On Sep 22, 10:11 pm, Peter <pete...@circ le-consulting.co.n zwrote:
      >
      >
      >
      >
      >
      Hi
      >
      I've discovered a bizarre Windows Forms (VB.NET) behavior that is
      resulting in a Form not being able to be moved.  To reproduce this:
      >
      1) Create yourself a new Windows Application in Visual Studio 2005.
      2) A project will be created with one Form (Form 1).  Don't add any
      code to the project.
      3) Run the project and confirm that Form 1 is displayed and you can
      drag the Form around your screen by clicking and dragging the Form's
      title bar, ie; standard Windows application behaviour.
      4) Now add the following code to Form 1:
      >
      Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As
      System.Windows. Forms.MouseEven tArgs) Handles Me.MouseDown
      >
              Beep()
      >
          End Sub
      >
      5) Now run the project again.
      >
      You will find that
      a) If you click the empty client area of the Form your PC will beep as
      you would expect.
      b) If you click Form 1's Title Bar or attempt to drag the Form the
      application will lock and you can't access the Minimise, Maximise or
      Close buttons on the Title Bar.  The Form seems to lock for about 30 -
      45 secs on my PC.
      >
      I discovered this issue in my main project and can't resolve it.  It
      seems that as soon as you declare a MouseDown event handler this
      problem will arise.
      >
      Anyone got any ideas about why this happening?
      >
      Peter,
      >
      I cannot duplicate the problem.  I was able to move the app by
      dragging the title bar as well as click the client area to hear the
      beep.
      >
      Microsoft Visual Studio 2005
      Version 8.0.50727.762  (SP.050727-7600)
      Microsoft .NET Framework
      Version 2.0.50727 SP2
      >
      Installed Edition: Professional
      >
      Chris- Hide quoted text -
      >
      - Show quoted text -
      Chris

      Thanks for trying this but I'm a little stumped now. I'm using the
      same version of Visual Studio and the .NET Framework as you. I'll try
      running the compiled application on another PC and see if the
      behaviour is the same.

      Peter,

      Comment

      Working...