473,503 Members | 10,012 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 1643
Hi,

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

Ken
------------------
"Eddie" <ma*************@videotron.ca> wrote in message
news:ua**************@tk2msftngp13.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.NotifyIcon.Text = "Test"
oForm.NotifyIcon.Icon = oForm.Icon
oForm.NotifyIcon.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***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

http://msdn.microsoft.com/library/de...ndingtopic.asp
Ken
------------------
"Eddie" <ma*************@videotron.ca> wrote in message
news:ua**************@tk2msftngp13.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.NotifyIcon.Text = "Test"
oForm.NotifyIcon.Icon = oForm.Icon
oForm.NotifyIcon.Visible = True

AddHandler Microsoft.Win32.SystemEvents.SessionEnding, New
SessionEndingEventHandler(AddressOf 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
2676
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,...
10
18617
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
1318
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...
2
1472
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...
5
6019
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...
5
3514
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...
0
1086
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...
5
2175
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...
1
1381
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...
0
7194
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
7070
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
7267
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,...
0
7449
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...
0
5566
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,...
1
4993
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...
0
3160
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...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
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...

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.