473,769 Members | 6,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

prevent user closing the application

Hello,

When the user try the close the application (click the top right side
button "X"), I would like to do a checking first. If the checking return
false, prevent the application terminate. Anyone know how to do it?
Thanks.
Nov 15 '05 #1
7 7121
private void Form1_Closing(o bject sender,
System.Componen tModel.CancelEv entArgs e)
{
if(some closing condition is not met)
{
e.Cancel = true;
}
}

Beware, this will also prevent windows from being able to close it when
you shut down your computer.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
Oh! Is there nothing like a VB:
Private Sub Form_QueryUnloa d(Cancel As Integer, UnloadMode As Integer)

Where 'UnloadMode' shows how the form is closing?

TIA
Krishnan
Codito Ergo Sum

"Morten Wennevik" <Mo************ @hotmail.com> wrote in message
news:opr0dccut8 hntkfz@localhos t...
private void Form1_Closing(o bject sender,
System.Componen tModel.CancelEv entArgs e)
{
if(some closing condition is not met)
{
e.Cancel = true;
}
}

Beware, this will also prevent windows from being able to close it when
you shut down your computer.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #3
off topic, but...

Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

is M2 that much better than OutlookExpress? (not that it would be too
difficult to achieve such a distinction)
Nov 15 '05 #4

Hi Krishnan,

Form_QueryUnloa d event is the feature of VB 6.0, while in VB.net, it is
upgraded to Closing event.
For more information about this, please refer to the link below:
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbup1057.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5
Thanks Jeffrey, but the link doesn't seem to work.

Krishnan Codito Ergo Sum
""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:ne******** *****@cpmsftngx a07.phx.gbl...

Hi Krishnan,

Form_QueryUnloa d event is the feature of VB 6.0, while in VB.net, it is
upgraded to Closing event.
For more information about this, please refer to the link below:
http://msdn.microsoft.com/library/de...us/vbcon/html/ vbup1057.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

Hi Krishnan,

I have tried the link, it really works.
I think you should place the 2 wrapped lines into one line:
Place
"http://msdn.microsoft. com/library/default.asp?url =/library/en-us/vbcon/html
/" with "vbup1057.a sp"

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #7
Not sure, never used it as an email client, but I use it as a news
reader. It seems to do fine handling tens of thousands of mails in each
group. The line is sort of a default signature and I haven't changed it
yet.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #8

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

Similar topics

11
2552
by: danny | last post by:
Is there a way I can prevent the browser window from being closed? I'd like to make sure the browser window only closes programatically (I want to make sure the user enters data before moving on). Another possible solution would be to re-open the window when it's closed. Any help is appreciated, thanks.
3
7166
by: waisty vb.net rookie | last post by:
How do I make sure my program cannot be closed by using Alt + F4 -- Thanks for reading
22
7581
by: alecjames1 | last post by:
I have a form which the user must complete before closing. I have disabled the window x button and use my own exit button. When selected it checks to see if the user has completed the entries otherwise it cancels the close. However, the user can still right click on the task bar and close my application. Is there any way of preventing this. Thanks Alex
7
7897
by: Nikki | last post by:
Hi, Can anybody help me, i want to prevent windows to close my winform of ..NET application, when user presses Alt+F4
9
2284
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx) as a popup using either window.open or window.showModalDialog. Since I want to warn the users of my application when they try to close page1.aspx and have changed the values in the meantime I thought about using the “onbeforeunload” event of the...
2
1943
by: Strahimir Antoljak | last post by:
Is it possible to prevent terminate the application (and how). I am aware of preventing the closing application, but here I mean on more violent cases when user tries to kill (terminate) the application process in the Windows Task Manager. Thanks, -- Strah @ Langan
2
3530
by: kevininstructor | last post by:
I want to prevent a user from closing an application while doing critical operations. The following code (concept came from MSDN) works except for when the user attempts to terminate via "Task List" which causes "Program not responding"...press "Cancel" and no issues, press "End now" and sure enough it ends. My question is; is there any method to prevent the "Application not responding" message from appearing? Current code:
2
2441
by: Lauren Wilson | last post by:
Hi folks, I believe I have seen this in this group in the past but my search comes up with nothing so far. I want to prevent our Access application from closing without some kind of confirmation from the user. We already have a tiny hidden form that loads from a function called by the autoexec macro. I KNOW it is loading because I placed a
0
1732
mbmccormick
by: mbmccormick | last post by:
My application is running in the background as a service, but whenever I logoff it closes. I want to somehow override the Form.WndProc() (?) and WMI (?) to prevent my application from closing. It is currently running under the SYSTEM user account. I'm not even sure this is possible, I just remember hearing something about it. Any help is appreciated. Thanks.
0
9589
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9423
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
10211
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...
1
9994
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
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5299
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
3959
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
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.