473,804 Members | 2,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,
Sep 23 '08 #1
2 2812
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

Sep 23 '08 #2
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,
Sep 23 '08 #3

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

Similar topics

12
24198
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 pressed and pass it to a standard subroutine that identifies what action should be taken. Unfortunately, I have a web-browser contol on the form and the webbrowser does not include a KeyPress event. I need some way to intercept keypress and...
2
16324
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
2916
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 textboxes. The datagrid and textboxes are populated from the same underlying SQL Server table but using different strongly typed data adapters and datasets for display and editing. So I coordinate syncronization of the two sets of data using code. I use...
7
8124
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 mousedown to handle mybase.mousedown but it doesn't detect the mousedown event until I move out of the pictureboxes I have created (only works on the part of the form where I don't have any pictureboxes). I also cannot set the mousedown event to...
4
4358
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 and Button2, on it (code below). When I press the mouse button over Button2, and don't release it, in the IDE output window it prints "Button2_MouseDown" only. If I release the mouse button over the button, over the form, or even over ANY other...
1
2797
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 Private Sub Label1_mouseup(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
1
5223
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 pressed while dragging the Form window to resize it. Can this "problem" be explained as some sort of by-design behavior? If so what is the work around to detecting when a user has completed resizing a Windows Form by way of mouse drag? / ...
2
3149
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 drawn between where the original click was and where I clicked to close the dialog. Until another mouse click occurs this rectangle resizes as you move the mouse. I guess this is because the MouseUp event hasn't fired yet (or fired on the modal...
6
7264
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 Sub TestTree_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = acRightButton Then MsgBox "" End Sub I get an error message when I try to open the form with the TreeView on it:
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.