Results 1 to 4 of 4

Thread: Ending app

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Wiesbaden, Germany
    Posts
    2

    Question

    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.

  2. #2
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Example

    Here's some code I've used and it copes with system shutdown :

    Code:
    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 :

    Code:
    If UnloadMode = vbAppWindows Then
    .
    .
    .
    End If
    hope this helps.
    That's Mr Mullet to you, you mulletless wonder.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Wiesbaden, Germany
    Posts
    2

    Arrow Re: Example

    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

  4. #4
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Lightbulb subclassing

    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.
    That's Mr Mullet to you, you mulletless wonder.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width