473,795 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form level MouseDown and MouseUp events don't seem to be working....

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?

/ Bare bones C# application to detect when user has completed a form
resize using mouse drag.
//
=============== =============== =============== =============== ==========
//
//
public partial class Form1 : Form
{
private int sizeHasChanged = 0;
private bool mouseDown = false;

public Form1()
{
InitializeCompo nent();

this.MouseDown += new MouseEventHandl er(Form1_MouseD own);
this.MouseUp += new MouseEventHandl er(Form1_MouseU p);

// resizeFinishedT imer is a .NET Timer control object
dropped onto the form in VS.NET designer
// It's Interval is set to 500 milliseconds
resizeFinishedT imer.Enabled = true;
}

void Form1_MouseUp(o bject sender, MouseEventArgs e)
{
mouseDown = false;

}

void Form1_MouseDown (object sender, MouseEventArgs e)
{
mouseDown = true;

}

private void Form1_SizeChang ed(object sender, EventArgs e)
{
sizeHasChanged = 1;
}

private void resizeFinishedT imer_Tick(objec t sender, EventArgs
e)
{
if (!(mouseDown))
{
if (sizeHasChanged == 1)
{
sizeHasChanged = 0;
MessageBox.Show ("Resize done");
}
}
}
}

Jun 22 '07 #1
1 5219
On Fri, 22 Jun 2007 11:19:43 -0700, JDeats <Je**********@g mail.comwrote:
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?
Not sure. If there's anything odd about the behavior you're seeing, it's
that you get the mouse-down event at all, given that the mouse is being
clicked on the non-client area of the window. But that may well be by
design; you'd have to look at the native Win32 API to know for sure.
If
so what is the work around to detecting when a user has completed
resizing a Windows Form by way of mouse drag?
Maybe the Form.ResizeEnd event is what you're looking for? But I see that
you've already been given that as an answer.

Pete
Jun 23 '07 #2

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

Similar topics

1
1694
by: Jeremy Robertson | last post by:
I'm working on an application that manages large image files (mulit-page ..Tiff's to be exact some 1000+ pages). I've written an user control that displays a number of the images as thumbnails in a scrollable window. The user can select and modify Images from my thumbnail control. I need to let the user re-arrange the images if they are out of order. I need the user to be able to click on a thumbnail or multiple and DRAG them to the...
0
1034
by: Doug | last post by:
Events such as ListControl 'item selected' or a command button stop firing from external browser or VS debugger. But if I debug and set breakpoint in the event, then it works. And then it starts working with external browser, as well, though I have not changed the source code.
4
1736
by: Samuel Hon | last post by:
Hi I'm building a custom control which basically takes data from the user and then submits it. I would use the validator controls but if I understand correctly (I've been working with .Net for 2 weeks) you cant 'embed' them in the custom controls. Someone correct me if I'm wrong (and please point to an example :) ) So, to get around this, I'm using Javascript. In my control, I'm doing
5
1647
by: Hazz | last post by:
I needed to provide client side validation for a web forms text box, radio button list, and drop down list. I asked two developers I work with what they thought I should do. One said Javascript, the other the Validation Controls. I chose the RequiredFieldValidator although I had done considerable work with Javascript in my ASP days. In 3-5 minutes I had two controls validated and working. It took me a little longer with the drop down...
2
1849
by: rt | last post by:
hi, iam a having a datagrid, pls check the code ---- Public WithEvents bgt As System.Web.UI.WebControls.DropDownList ---
16
6678
by: schneider | last post by:
I can't get any of the Key events to fire in my UserControl. The control only contains a few labels. This is really annoying.. Anyone know whats going on? Thanks, Schneider
0
1080
by: Tom Edelbrok | last post by:
To all: I am new to Visual Studio 2005 (VB.NET) and am writing my first web application. I see that controls, when double-clicked at design time, show you code for events that fire. In fact this works great, as follows: Partial Class _Default Inherits System.Web.UI.Page
1
2139
by: Kenneth Baltrinic | last post by:
I am having a very odd problem. On a page that was working until very recently we are now encountering the following situation: The page is a very basic fill in the blank form used for changing ones password in a forms based authentication scenario. After the user fills out the form and clicks the Change Password button, the page simply reloads as if nothing happened. We turned on page tracing and also added the following lines to the...
4
1647
by: divy24 | last post by:
I'm new to VB 6.0 as I'm a C# developer originally. I'm working on an application with hundreds of forms spread across multiple projects. Can any VB expert please guide me if there is a way of capturing form-level events at the application level at a common place so that my efforts are reduced? Otherwise, I'll have to make changes at the form level which will be quite cumbersome due to large no. of forms. I need to catch events to keep track of...
0
9672
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
9519
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,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
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,...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
3
2920
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.