kedaman,
how do i tell my program that a shutdown attempt is occuring.
Thanks,
ande211
Printable View
kedaman,
how do i tell my program that a shutdown attempt is occuring.
Thanks,
ande211
Well, Kedaman, you have succeeded AGAIN to confuse everyone. At least you are semi-right, but you haven't given enough information (I think) to make any use of this.
I will assume that a shutdown event in ande211's message means the Windows shutdown. (Start|Shutdown)
Very simply, without using any API stuff, the one event on your forms that helps you to know that you form is shutting down is called Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer).
This is where you want to evaluate what kind of unload is being processed. If you look in the VB Help for QueryUnload you will see that the UnloadMode argument provides you with lots of information about HOW your program is being closed.
The one you will probably be interested in is vbAppWindowsCode:Constant Value Description
vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
vbFormOwner 5 A form is closing because its owner is closing
If you examine the UnloadMode = vbAppWindows then you will be able to tell exactly how your program is shutting down.
I'm confusing everyone? That's the last thing I want! If this is about the doevents thing, ande211, then the form will know. It will also know when user closes it. If you really want the track the shutdown attempt, I think Jaguar have the right code. But I don't know what you mean, you posted "kedaman", and I suppose it was about the doevents. Sorry if I really was confusing anybody. :o