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

Prompt User Before Application.Exit

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.exit.

'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?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) =
Windows.Forms.DialogResult.No Then
e.Cancel = True
Me.ParentForm.Activate()
End If
Aug 22 '06 #1
1 7015
Put this and only this in your form closing event.

If MsgBox("Are you sure you want to quit?", MsgBoxStyle.YesNo) =
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.exit.

'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?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) =
Windows.Forms.DialogResult.No Then
e.Cancel = True
Me.ParentForm.Activate()
End If
Aug 22 '06 #2

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

Similar topics

5
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...
6
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...
3
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...
0
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...
5
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...
11
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...
4
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...
9
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...
1
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...
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
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
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,...
0
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...
0
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...
0
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...

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.