Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Avoiding Windows Shutdown.

Posted on 1998-09-11
5
Medium Priority
?
125 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 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