Solved

Avoiding Windows Shutdown.

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now