473,765 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bypass a Close Application MessageBox

Sometimes users (including myself) accidentally click on the application
close icon in the application menu bar when they meant to just click on the
'X' for the form. Of course the app closes and this is very annoying.

So, I added a messagebox to my hidden StartAppForm in the Unload event. Now
when the application closes the user is presented with a message so they can
abort closing in case they don't really want to close. This has been working
very well.

However, I forgot that there are cases where I want to force a shutdown
regardless of what the user wants (i.e. user doesn't agree to license, etc).
I'm using either DoCmd.Quit or Application.Qui t in these instances. When this
happens, the afore-mentioned messagebox appears "Do you really want to close
the application" with a Yes/No button. Regardless of what the user selects,
the app closes. While this is not a showstopper and an events occur as I want
them to, the appearance of this messagebox in this case looks unprofessional.

So I thought I would just add a global boolean variable: BypassCloseMess age.
This variable would be set to True just before any DoCmd.Quit or Application.
Quit code statement. Then in the hidden StartAppForm Unload event, the code
would check the value of this global boolean variable. If True, bypass the
messagebox and continue closing.

I thought that this would work. However, it doesn't. I've checked the code
and it looks correct.

When using the DoCmd.Quit or Application.Qui t command, does this cause the
global variables to go out of scope immediately. I tried putting a break in
the StartAppForm Unload event, but the code won't stop there after the DoCmd.
Quit or Application.Qui t command has been invoked. The application closes and
disappears from the screen. BUT, the messagebox "Do you really want to close
the application" does appear as the last thing on the screen (even though the
rest of the app is no longer viewable). Regardless of what the user selects
it is then closed.

So how can I solve my problem and it would be great if someone could explain
why this behaviour is occurring.

Thanks

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 3 '06 #1
3 4156
I think I've found the solution.

After some more research I discovered discussions where the Quit command
causes global variables to go out of scope, which is what I seem to be
experiencing.

So instead of setting a global variable. I have now added a checkbox to my
StartAppForm, which I set to True just prior to calling the DoCmd.Quit
command.

Now everything seems to be working fine, but I need to do more testing. I
should have coded it this way earlier, since I'm trying to get away from
global variables.

rdemyan wrote:
>Sometimes users (including myself) accidentally click on the application
close icon in the application menu bar when they meant to just click on the
'X' for the form. Of course the app closes and this is very annoying.

So, I added a messagebox to my hidden StartAppForm in the Unload event. Now
when the application closes the user is presented with a message so they can
abort closing in case they don't really want to close. This has been working
very well.

However, I forgot that there are cases where I want to force a shutdown
regardless of what the user wants (i.e. user doesn't agree to license, etc).
I'm using either DoCmd.Quit or Application.Qui t in these instances. When this
happens, the afore-mentioned messagebox appears "Do you really want to close
the application" with a Yes/No button. Regardless of what the user selects,
the app closes. While this is not a showstopper and an events occur as I want
them to, the appearance of this messagebox in this case looks unprofessional.

So I thought I would just add a global boolean variable: BypassCloseMess age.
This variable would be set to True just before any DoCmd.Quit or Application.
Quit code statement. Then in the hidden StartAppForm Unload event, the code
would check the value of this global boolean variable. If True, bypass the
messagebox and continue closing.

I thought that this would work. However, it doesn't. I've checked the code
and it looks correct.

When using the DoCmd.Quit or Application.Qui t command, does this cause the
global variables to go out of scope immediately. I tried putting a break in
the StartAppForm Unload event, but the code won't stop there after the DoCmd.
Quit or Application.Qui t command has been invoked. The application closes and
disappears from the screen. BUT, the messagebox "Do you really want to close
the application" does appear as the last thing on the screen (even though the
rest of the app is no longer viewable). Regardless of what the user selects
it is then closed.

So how can I solve my problem and it would be great if someone could explain
why this behaviour is occurring.

Thanks
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 3 '06 #2
rdemyan via AccessMonster.c om wrote:
I think I've found the solution.
My solution has been to keep my applications very, very simple. I have
not written very much that saves a user from himself/herself. My
clients (past as I am no longer in business) have always liked this. So
have I.

Dec 3 '06 #3
Append the BypassCloseMess age to the messagebox so you can see if it is true
or false.
By definition, a gobal variable is global AS LONG AS ITS NOT IN A PROCEDURE.
stick it right at the top of a module, not on a form either.
everythng else you have done seems logical.

"rdemyan via AccessMonster.c om" <u6836@uwewro te in message
news:6a3736d9bd 68c@uwe...
Sometimes users (including myself) accidentally click on the application
close icon in the application menu bar when they meant to just click on
the
'X' for the form. Of course the app closes and this is very annoying.

So, I added a messagebox to my hidden StartAppForm in the Unload event.
Now
when the application closes the user is presented with a message so they
can
abort closing in case they don't really want to close. This has been
working
very well.

However, I forgot that there are cases where I want to force a shutdown
regardless of what the user wants (i.e. user doesn't agree to license,
etc).
I'm using either DoCmd.Quit or Application.Qui t in these instances. When
this
happens, the afore-mentioned messagebox appears "Do you really want to
close
the application" with a Yes/No button. Regardless of what the user
selects,
the app closes. While this is not a showstopper and an events occur as I
want
them to, the appearance of this messagebox in this case looks
unprofessional.

So I thought I would just add a global boolean variable:
BypassCloseMess age.
This variable would be set to True just before any DoCmd.Quit or
Application.
Quit code statement. Then in the hidden StartAppForm Unload event, the
code
would check the value of this global boolean variable. If True, bypass the
messagebox and continue closing.

I thought that this would work. However, it doesn't. I've checked the code
and it looks correct.

When using the DoCmd.Quit or Application.Qui t command, does this cause the
global variables to go out of scope immediately. I tried putting a break
in
the StartAppForm Unload event, but the code won't stop there after the
DoCmd.
Quit or Application.Qui t command has been invoked. The application closes
and
disappears from the screen. BUT, the messagebox "Do you really want to
close
the application" does appear as the last thing on the screen (even though
the
rest of the app is no longer viewable). Regardless of what the user
selects
it is then closed.

So how can I solve my problem and it would be great if someone could
explain
why this behaviour is occurring.

Thanks

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 4 '06 #4

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

Similar topics

0
1095
by: Hawk Wu via DotNetMonster.com | last post by:
Hello, I have odd problem. When I close my application wait around 5 minute. The pocket of screen will show one message "System.Net.Sockets.Tcpclient" of message box. My source code as below. Dim t1 as TcpClient Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles MyBase.Load Dim bf(255) As Byte t1.GetStream.BeginRead(bf, 0, 255, AddressOf DoRead, Nothing)
4
10092
by: PawelR | last post by:
Hello group, In my apps I connection to SQL database. try { //connect to db } catch { MessageBox("Error Connect. Close Apps?","Sql Error",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
1
1843
by: Ebrahim | last post by:
This message is in reply to a prev 1 . My application refues to close . Some one had suggested that I might have threads running.. but i solved that problem too . The app still refuses to close . !! Here is the code for one of them !! I call a stop function to disconnect all objects (close ) . I also make a call to Stop in the Dispose() function .
1
5496
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the following code after the "Application.Run(new VMSMain());": static void Main() { Application.Run(new VMSMain()); }
7
2242
by: mg | last post by:
Once opening WebForm2 from WebForm1 using Response.Write("<script language='javascript'>window.open ('WebForm2.aspx','two','menubar=no');</script>"); how can I close WebForm1?
5
1695
by: Nicola Farina | last post by:
Hi all, I've a window form application with 3 forms. I want to catch the security exception when users run this application from a network share, thus I've made this code (I've notice that excpetion has been throw by initializecomponent()): Try InitializeComponent() Catch ex As Security.SecurityException
4
3697
by: pamelafluente | last post by:
Hi Guys, I have a small application which uses a NotifyIcon. The user can set a flag (PreventClosing ) so that when he clicks on the form-cancel button "X", the program will instead be minimized in the icon try. See code attached. My problem is that my code is probably too naive. In fact there is a problem when one tries to shut dow or restart Windows. Windows does NOT want to shut down! I guess it's the e.cancel = TRUE statement in...
6
21557
by: Frank Rizzo | last post by:
I am trying to programmatically close a messagebox. I don't see any obvious managed choices. Back in the day, I remember using a combination of FindWindow and EndDialog apis( http://msdn2.microsoft.com/en-us/library/ms645472.aspx ), but how can I ensure that the dialog that I am destroying actually belongs to my application? Thanks.
1
5881
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi all, I have got my windows app to handled any UI or unhandled exceptions. following is the code static class Program { /// <summary> /// The main entry point for the application. /// </summary>
0
9566
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
10153
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...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
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
9832
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
8830
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7371
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...
1
3921
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
3
2800
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.