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

Windows Forms Control Box

How can I tell if a user clicks the Close "X" on the windows form control box?
--
Dennis in Houston
Nov 21 '05 #1
7 6305
Dennis wrote:
How can I tell if a user clicks the Close "X" on the windows form control box?


If I remember correctly you have to override the mouse click event for
the form and the calculate if it is in that section. I could be wrong,
and I'm sure someone will correct me if I am.

Chris
Nov 21 '05 #2
Choose the Form's Closing event

You have 'e'. So, you could say:

e.Cancel = True

This means if the user clicks the ControlBox the application isn't closed,
but is handled how you need it. So this in conjunction of the Form_Closing
event is what you need

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3
Crouchie,

e.Cancel = True

This was not asked and I hope that Dennis will not implement this or he
should use a messagebox to ask by instance if closing true should be done.

In the other case *I* see it, when it is implemented as you wrote, as a bug.

There are possibilities to disable the X what than is in my opinion a good
solution..

Cor
Nov 21 '05 #4
"Dennis" <De****@discussions.microsoft.com> schrieb:
How can I tell if a user clicks the Close "X" on the windows form control
box?


<URL:http://web.archive.org/web/20041113033054/http://fawcette.com/archives/premier/mgznarch/vbpj/2001/11nov01/qa0111/qa0111.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
If I have a button, "Apply" on the form and the user clicks it and I close
the form in this button click event, then the form closing event fires also
so I don't know which action the user took in the Form Closing event, i.e.,
clicked the button or the control box close. I know I could set a form
scoped variable boolean and set it to true in the button click event then
check it in the control box close event but I was hoping for something a bit
more elegant!

"Crouchie1998" wrote:
Choose the Form's Closing event

You have 'e'. So, you could say:

e.Cancel = True

This means if the user clicks the ControlBox the application isn't closed,
but is handled how you need it. So this in conjunction of the Form_Closing
event is what you need

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #6
That's the only way I've found so far...not very neat but it does work.

"Chris" wrote:
Dennis wrote:
How can I tell if a user clicks the Close "X" on the windows form control box?


If I remember correctly you have to override the mouse click event for
the form and the calculate if it is in that section. I could be wrong,
and I'm sure someone will correct me if I am.

Chris

Nov 21 '05 #7
Thanks...I'll study it as I've not actually used WinProc before but now's as
good a time as any.

"Herfried K. Wagner [MVP]" wrote:
"Dennis" <De****@discussions.microsoft.com> schrieb:
How can I tell if a user clicks the Close "X" on the windows form control
box?


<URL:http://web.archive.org/web/20041113033054/http://fawcette.com/archives/premier/mgznarch/vbpj/2001/11nov01/qa0111/qa0111.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8

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

Similar topics

2
by: Greg Bacchus | last post by:
Hi, I'm getting an exception that really has me stumped. It's sporadic at best, it's only happened a handful of times. This particular time it happened when the user pressed 'Alt-S' to save the...
5
by: Dave | last post by:
How do I check in a Windows Forms app if any controls have changed? I have a form that collects data, and I want to prompt the user if they try to exit the app, or load a new file, without saving...
1
by: Günther Rühmann | last post by:
Hi, I´m not sure if i´m right int this group... My problem: I made a vb .net application that reads from AD via System.Directoryservices.Directoryentry. The appliocation enumerates group...
7
by: Tyler Foreman | last post by:
Hello, I have a strange problem that occurs every so often in my application. It usually takes place when I hide one form and activate another. What happens is I get the following exception:...
9
by: Günther Rühmann | last post by:
Hi, I´m not sure if i´m right int this group... My problem: I made a vb .net application that reads from AD via System.Directoryservices.Directoryentry. The appliocation enumerates group...
1
by: harinathch | last post by:
Hi, Iam working with myapplication.exe.config file in my vb.net windows application.Its working fine in my development environment. When i test this application in some other machine using exe and...
0
by: gxl034000 | last post by:
Hi, I have been trying to use a .net Forms control in my webpage to open up an application(notepad) on the client. The control works fine when embedded in a windows form, but I keep getting a...
2
by: Budhi Saputra Prasetya | last post by:
Hi, I managed to create a Windows Form Control and put it on my ASP .NET page. I have done the suggestion that is provided by modifying the security settings. From the stack trace, I would...
0
by: Budhi Saputra Prasetya | last post by:
Hi, I still have the same problem with embedding Windows Control. I'll just requote what I posted last time: I managed to create a Windows Form Control and put it on my ASP .NET page. I...
3
by: shobhitguptait | last post by:
How to Run C#.NET Windows App on N/W with centralized DB using SQL SERVER 2000 Hello All...i m really grate full to c such a website where developers try to help people like us who face problems...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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.