Click to See Complete Forum and Search --> : Ending app
ky
Jul 3rd, 2000, 04:47 AM
I have a little problem with one of my apps. On forms unload i want to save the current record. No problem with QueryUnload (calling a procedure to save it), but if the unload request comes from the system (shutdown, etc.) this special event (shutdown) stops! Now I'm looking for an indicator to restart this system request.
Paul Warren
Jul 5th, 2000, 05:12 AM
Here's some code I've used and it copes with system shutdown :
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'********************************************************************************
Dim intReply As Integer
' bChanged just indicates that the user has changed some
' data so prompt for saving if that's true
If bChanged Then
intReply = MsgBox("Do you want to save your changes first ?", vbYesNo, "Task Manager ?")
If intReply = vbYes Then
Save_List
End If
End If
End
End Sub
You can check for the type of shutdown by checking the UnloadMode as follows :
If UnloadMode = vbAppWindows Then
.
.
.
End If
hope this helps.
ky
Jul 5th, 2000, 08:37 AM
Paul, thanks for your answer,
... but the problem is, that the system request (for example "shutdown") STOPPS (!), when I save the record with my function! It stopps and the user must restart it, ... shutdown! What I want to know is the specific request to restart it by myself, in code. The constant "vbAppWindows" tell me only that the shell want to unload my app, but not why...(restart, shutdown,...???)
I hope you have any idea ...
Kristof
Paul Warren
Jul 6th, 2000, 03:06 AM
I've had a good look around to see if there's anything out there which might give you the answer but I the could not find the answer. However, subclassing seems to be one way forward. You can create your own winproc and intercept windows messages to your application. At shutdown the message recieved is WM_QUERYENDSESSION and from there you should be able to find out more information.
It's probably worth asking this question in C/C++ groups as it's something they might make use of more than VB users.
Sorry I can't be of any more help but if you find an answer can you post it because it would be a useful thing to know.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.