Solved

Avoiding Windows Shutdown.

Posted on 1998-09-11
5
118 Views
Last Modified: 2010-04-30
I have a large 16 bit VB4 application that runs in both Windows 3.11 and 95.

It utilises an MDI form.

If someone tries to exit Windows I would like Windows to tell the user to exit my application first.

Ideally windows will generate this message.

Can I do this?  In either or both operating systems.


0
Comment
Question by:deighton
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1434361
What you can do is add some code in your form's unload querry to accomplish that.
0
 
LVL 18

Author Comment

by:deighton
ID: 1434362
I'm not sure about that - how do I tell windows not to shut down anymore in the unload query event?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1434363
deighton,
in the form's QueryUnload event, try:

If UnloadMode =2  Then
            ' Window is shutting your app down
            Msgbox "Please close VB App first"
                Cancel = True
End if

You can search the online help on QueryUnload
Regards
Dalin      
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1434364
deighton,
Sorry, it did not work.
I was under the impression it can be done. I guess I was doing the other way around (do something when it was not system shutdown).  
I appologize to you and other viewer of this question,  for the mistake. Please reject my answer.
Meanwhile, I will see if I can find somthing.
Regards
Dalin
0
 
LVL 18

Author Comment

by:deighton
ID: 1434365
That does work thanks!  

Just for your info here's my code

    'AD : 14/9/98 : Try to prevent shutdown if autogrpah is running
    If UnloadMode = vbAppWindows Then
       
        Dim vDummy
        On Error Resume Next
       
        If frmAutograph.WindowState = 1 Then
             frmAutograph.WindowState = 2
        End If
       
        frmAutograph.SetFocus

        vDummy = MsgBox("Autograph is still active." & vbCrLf & "Please exit Autograph before" & vbCrLf & "attempting to shutdown Windows.", vbSystemModal + vbExclamation + vbOKOnly, "Autograph Warning")

        Cancel = True
       
        On Error GoTo 0

       
    End If


I used put this in the query unload event of the projects MDI form, the Msgbox is system modal, that could be a factor.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question