473,378 Members | 1,156 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,378 software developers and data experts.

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()
{
InitializeComponent();

this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.MouseUp += new MouseEventHandler(Form1_MouseUp);

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

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

}

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

}

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

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

Jun 22 '07 #1
1 5188
On Fri, 22 Jun 2007 11:19:43 -0700, JDeats <Je**********@gmail.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
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...
0
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...
4
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...
5
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,...
2
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
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
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...
1
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...
4
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.