473,414 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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.MouseEventArgs) 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,
Sep 23 '08 #1
2 2793
On Sep 22, 10:11 pm, Peter <pete...@circle-consulting.co.nzwrote:
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.MouseEventArgs) 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

Sep 23 '08 #2
On Sep 24, 1:26*am, Chris Dunaway <dunaw...@gmail.comwrote:
On Sep 22, 10:11 pm, Peter <pete...@circle-consulting.co.nzwrote:


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.MouseEventArgs) 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,
Sep 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Trevor Fairchild | last post by:
I'm writing a program that is designed for quick navigation using specific buttons on the keyboard. In doing this, I have added a KeyPress event for every control on the form to intercept the key...
2
by: JJ | last post by:
Hi All, I need to create a MouseDown event for a picture box . Am I doing the following right? pictureBox.MouseDown += new System.WinForms.MouseEventHandler(pictureBox_MouseDown) Then
1
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the...
7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
4
by: Colin McGuire | last post by:
Hi again, thanks everyone for your previous help. But having resolved past problems, I'm moving on to new problems :( This one is a simple winforms application with two buttons, named Button1...
1
by: Alan | last post by:
i have a form with a label on it Private Sub Label1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown ' do stuff End Sub ...
1
by: JDeats | last post by:
It appears the WinForm MouseDown and MouseUp event handlers are not working properly. In the "bare bones" sample application below, Form1_MouseUp gets called even through the mouse button remains...
2
by: charlieopenshaw | last post by:
I have a form listview and have used the MouseDown event to launch a modal dialog if a particular cell is clicked. This works fine but upon closing the dialog I am left with a dotted rectangle...
6
by: jpatchak | last post by:
Hello, I am trying to create a context menu for right clicking on a TreeView control (for deleting, etc...), using either the MouseDown or MouseUp event. When I put following code in: Private...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.