Solved

Avoiding Windows Shutdown.

Posted on 1998-09-11
5
117 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now