?
Solved

Avoiding Windows Shutdown.

Posted on 1998-09-11
5
Medium Priority
?
122 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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