473,796 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form_Closing + Shutting down Computer

Hi All,

In my application, every time the user "Close" the form, I cancel the close
and I put a NotifyIcon in the systray. Here is my code :

Private myForm_Closing( ... ... ...) Handels MyBase.Closing
e.Cancel = True
End sub

My problem is : When the user try to shut Down his computer, My application
cannot close, so the computer does not shut down...

How May I know if the form is closing because the close click the X button
or because the computer is shutting down ?
Thx for your help...
Eddie
Nov 20 '05 #1
4 1659
Hi,

http://msdn.microsoft.com/library/de...ndingtopic.asp

Ken
------------------
"Eddie" <ma************ *@videotron.ca> wrote in message
news:ua******** ******@tk2msftn gp13.phx.gbl...
Hi All,

In my application, every time the user "Close" the form, I cancel the
close
and I put a NotifyIcon in the systray. Here is my code :

Private myForm_Closing( ... ... ...) Handels MyBase.Closing
e.Cancel = True
End sub

My problem is : When the user try to shut Down his computer, My
application
cannot close, so the computer does not shut down...

How May I know if the form is closing because the close click the X button
or because the computer is shutting down ?
Thx for your help...
Eddie

Nov 20 '05 #2
Thank you Ken...

It works only if I Start My application with a Form.
The problem is that I Start My Application without form... Only with a
NotifyIcon... like this :

-------------------------------
Public Sub Main

Dim oForm as New Form1
oForm.NotifyIco n.Text = "Test"
oForm.NotifyIco n.Icon = oForm.Icon
oForm.NotifyIco n.Visible = True

Application.Run ()

End Sub
-------------------------------

If I don't start with a Form, the event is not fired...

Any Ideas ?

Thanks again...

Eddie

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi,

http://msdn.microsoft.com/library/de...ndingtopic.asp
Ken
------------------
"Eddie" <ma************ *@videotron.ca> wrote in message
news:ua******** ******@tk2msftn gp13.phx.gbl...
Hi All,

In my application, every time the user "Close" the form, I cancel the
close
and I put a NotifyIcon in the systray. Here is my code :

Private myForm_Closing( ... ... ...) Handels MyBase.Closing
e.Cancel = True
End sub

My problem is : When the user try to shut Down his computer, My
application
cannot close, so the computer does not shut down...

How May I know if the form is closing because the close click the X button or because the computer is shutting down ?
Thx for your help...
Eddie


Nov 20 '05 #3
* "Eddie" <ma************ *@videotron.ca> scripsit:
It works only if I Start My application with a Form.
The problem is that I Start My Application without form... Only with a
NotifyIcon... like this :


Are you sure you set up a handler? Post the code you used to handle the
'SessionEnding' event.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
I tried to set up a handler in many sub...
---------------------------------------
Public Sub Main

Dim oForm as New Form1
oForm.NotifyIco n.Text = "Test"
oForm.NotifyIco n.Icon = oForm.Icon
oForm.NotifyIco n.Visible = True

AddHandler Microsoft.Win32 .SystemEvents.S essionEnding, New
SessionEndingEv entHandler(Addr essOf SessionIsEnding )
Application.Run ()

End Sub
---------------------------------------
I also tried to Set up the Handler in the Form_Load Event...

If I start My Applicatiotion directly with the Form, it works perfectly...

Any Help will be appreciate...

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:c7******** ***@ID-208219.news.uni-berlin.de...
* "Eddie" <ma************ *@videotron.ca> scripsit:
It works only if I Start My application with a Form.
The problem is that I Start My Application without form... Only with a
NotifyIcon... like this :


Are you sure you set up a handler? Post the code you used to handle the
'SessionEnding' event.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Nov 20 '05 #5

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

Similar topics

6
2707
by: EW | last post by:
I have a problem when using the python script found here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 It is a script to remotely shutdown a windows computer. When I use it, the computer shuts down, but doesn't power off like with a regular shutdown. It stays on the "Safe to power off" screen and I have to push the power button to actually power off. Anyone know why this happens with this script? Thanks for any...
10
18662
by: Jesper | last post by:
Does anyone know some c++ code for shutting down windows? I want to write a program using borland c++ builder to shut down windows. --
1
1341
by: Phoenix | last post by:
Is there any way to disable being able to shut down a program totally? I would have to allow it to be closed when the computer is shutting down or the user is logging out, but other than that it can't shut down no matter what. Can anybody give me any suggestions? I'd like to use c# but moreover I just need some direction in where to go with this.. Somebody had suggested to me to make a service that monitors the app running as a user on a...
2
1487
by: Richard Jonas | last post by:
I've written a Windows Application in C#.net that runs in the background and silently archives files to a network drive (using the System.IO.File.Copy function). Sometimes, users may run this application when connected to our network via a dial-up connection. This means that files take a long time to copy. If users try and shut down their computer whilst a file is copying, an error message is shown and the only way to shut down the...
5
6034
by: mdb | last post by:
I have an app that I want to keep open (and hidden with an icon in the taskbar) when the user presses the 'X' close window button. So I capture the Closing event on the form and check a bool variable, which if set, sets e.Cancel on the ClosingEventArgs and sets the Form.Visible=false and the Form.ShowInTaskbar=false. I have a menu item in the window that allows the user to actually exit the program by unsetting the bool and then exiting....
5
3525
by: DraguVaso | last post by:
Hi, I have a MDIForm with some MDIChilds. When the user clicks on the "x" in the upper right corner, I don't want the MDIChild to be closed, but the property Visible = False. So far no problem: I do this useing the Form_Closing-event in which I typed: e.Cancel = True Me.Visibible = False
0
1098
by: Sidney | last post by:
Dear, I am writting a system which opened at the system tray. But every before I shut down my computer, I have to close the system first. However, it should be automatically close when I shutting down my system. So, I want to know how I can do so that it can close up itself when the computer shut down. Thank You!! Sidney
5
2197
by: NEWSGROUPS | last post by:
I have some users that continuously end task on my database when a search takes to long. In turn corrupting the application. Is there any way to prevent this? The Microsoft KB for Methods That Can Be Used to Prevent Corruption suggests not allowing Task Manager to shut down the application but gives no way to prevent this. Any suggestions would help. Thanks in advance, Mark
1
1392
by: =?Utf-8?B?UHVycGxlIExlbW9u?= | last post by:
The last day or two the ctfmon.exe keeps "Encountering a problem" and shutting down when I start the computer, and when I open up either Netscape Browser or Internet Explorer. I have no idea why this has just started up, as I've not done anything to the computer in a while. Last thing I did was upgrade Internet Explorer, but it's been working for a few weeks now without a hitch, so if it is that I'm not sure why it would only start errors...
0
9685
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
9531
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
10459
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
7553
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
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
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
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
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
2928
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.