473,790 Members | 3,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prompt User Before Application.Exi t

I have a MDI Application and would like to prompt the user before exit. I
placed the following in the FormClosing event. It appears to work properly,
however when a user answers no to the question it causes the application to
flash and deactivate. I was able to activate it again but it looks sort of
stupid to have the application flash when it should simply return the user
to the app.

Any ideas around this? I know I can do it easliy with exit on the main menu
but the problem still exists when the user presses the X in the upper corner
thus causing the application.exi t.

'Check to see if the user want's to exit before closing the menu.
If MessageBox.Show ("Are you sure you want to exit?", "Exit?",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question,
MessageBoxDefau ltButton.Button 1, MessageBoxOptio ns.DefaultDeskt opOnly) =
Windows.Forms.D ialogResult.No Then
e.Cancel = True
Me.ParentForm.A ctivate()
End If
Aug 22 '06 #1
1 7045
Put this and only this in your form closing event.

If MsgBox("Are you sure you want to quit?", MsgBoxStyle.Yes No) =
MsgBoxResult.No Then e.Cancel = True

Izzy

Chris Cairns wrote:
I have a MDI Application and would like to prompt the user before exit. I
placed the following in the FormClosing event. It appears to work properly,
however when a user answers no to the question it causes the application to
flash and deactivate. I was able to activate it again but it looks sort of
stupid to have the application flash when it should simply return the user
to the app.

Any ideas around this? I know I can do it easliy with exit on the main menu
but the problem still exists when the user presses the X in the upper corner
thus causing the application.exi t.

'Check to see if the user want's to exit before closing the menu.
If MessageBox.Show ("Are you sure you want to exit?", "Exit?",
MessageBoxButto ns.YesNo, MessageBoxIcon. Question,
MessageBoxDefau ltButton.Button 1, MessageBoxOptio ns.DefaultDeskt opOnly) =
Windows.Forms.D ialogResult.No Then
e.Cancel = True
Me.ParentForm.A ctivate()
End If
Aug 22 '06 #2

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

Similar topics

5
7494
by: Gord | last post by:
Hello, If you set the flag for an overwrite prompt using the 'Save' common dialog, how do you read the response when the user clicks the Yes or No in the 'overwrite' message box? Everything I've read explains about setting the flag to bring up the overwrite prompt message box, but there's no explanation on how to read the response to it. It appears that clicking the Yes option doesn't actually overwrite the old file, so I assume I'm...
6
14598
by: Paul Deverson | last post by:
I'm a newbie to MySQL and am really confused about when I should be using the Command Line Client and when the DOS prompt. I'm using Windows XP and I've just installed MySQL 4.1.10. I can use the Command Line Client to logon as 'root'. It prompts me for a password and then I can create databases, etc. from the mysql prompt. However, if I wanted to logon as a different user, I'm not sure how to do it.
3
7888
by: J.P. Cummins | last post by:
In my ASP.NET application, I wish to have a page for administrators to edit items in a list. Preferably, I would like to use the javascript prompt for the 'rename' function, and a javascript alert box for the 'delete' function. When the user clicks 'rename', the javascript prompt asks for the new name. When the user clicks 'delete', a javascript alert asks the user if he really wants to delete that item. Here is an example of what my...
0
269
by: jburkle | last post by:
The following is the onclick method called when the "Renew" button is clicked by the user in my Windows application: ..... Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRenew.Click Try If x Is Nothing Then
5
2323
by: repairman2003 | last post by:
I'm writing a command prompt for unix and I've run into some problems: #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <stdlib.h> #define EXIT "exit"
11
3635
by: gopal | last post by:
Hi, I am trying to call the OSQL utility from my C# console application and i am having problems i have the following code In Main method ProcessStartInfo psi = new ProcessStartInfo("osql",""); psi.RedirectStandardInput = false;
4
10518
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
9
12118
by: edwardscm | last post by:
Hi, i am new to PL/SQL scripting, and need a script to have our operators who run our end of day processes to run their own Oracle PL/SQL and then based on the results of the SQL be prompted to commit or rollback. The basic logic would look like (this would allow us to save alot of overtime cost paid to the supporting DBA staff):- SQL> update tablea set c = d; 1 row updated display "Commit? " prompt accept user's response if user's...
1
4245
by: robtyketto | last post by:
Greetings, For my DESKTOP application I have more than one exit button where I would like the user to be prompted to confirm they really wish to exit. Much like in VBA with msgbox VbYesNo functionality. I haven't got a message box within my installed components at the moment. I've seen fscommand("messagebox") functionality mentioned to, I assume this is more webpage/server side orientated though. Wondering if there is an easy way to...
0
9666
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
9512
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
10147
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
7531
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
5424
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...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
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
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2910
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.