Results 1 to 2 of 2

Thread: Close application - send event to all open forms

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    76

    Post

    Let me divide my problem into 2 parts

    If i click on the main form close button - Iam asking the user do u really wish to exit
    1. if the user says i need to close all open forms that means send windows message to close the forms - may be if data entry is going on in those forms i may do something but i need the message to go to all open forms.

    2.Now if the user says no i need to stay in the application but the main forms close executes form unload and my whole app. closes

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Put your code in the QueryUnload Event of the Form, then if the user doesn't really want to Quit, you can set the Cancel Parameter to any Non-Zero Value to Cancel the Unload Process, ie.
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Dim oFRM As Form
        
        If MsgBox("Do you really want to Exit?", vbQuestion + vbYesNoCancel, "Exit") = vbYes Then
            For Each oFRM In Forms
                Unload oFRM
                Set oFRM = Nothing
            Next
        Else
            Cancel = True
        End If
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    ajyoung@pressenter.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width