Ciao tecnoguru,
quindi vuoi chiudere tutte le Frm ed uscire dal programma ?!
Prova queste routine, che naturalmente dovrai adattare alle tue necessità.
Da inserire nel modulo della MDIFrm:
codice:
Option Explicit
Dim byEsci As Byte
Dim intDomEsci As Integer
'-------------------------------------------------------------------------
' Esce dal programma con il clic sulla X:
Private Sub MDIForm_QueryUnload(Cancel As Integer, unloadMode As Integer)
' Invia al Comando di menu Esci:
If byEsci = 0 Then
Call mnuFileEsci_Click
End If
' Annulla Esci dal programma:
If intDomEsci = 2 Then
Cancel = True
End If
End Sub
'-------------------------------------------------------------------------
Private Sub mnuFileEsci_Click()
' Variabile di controllo Esci:
byEsci = 0
intDomEsci = MsgBox("Volete Uscire dal programma ?" & Chr(13) _
& "Clic su OK per Chiudere il programma - su Annulla per continuare.", vbQuestion + vbOKCancel, "Prova")
If intDomEsci = 1 Then
byEsci = 1
'Chiama la routine Esci - MDIFrm:
Call MDIFrm.Esci2
End If
' Annulla non esce dal programma:
If intDomEsci = 2 Then
' Se ridotta a icona Massimizza:
'Call mnuPopMax_Click
Exit Sub
End If
End Sub
'-------------------------------------------------------------------------
Public Sub Esci2()
DoEvents
' Modulo Tools - Suono GRPITOOT.WAV:
'Call SoundExit
Dim Frm As Form
For Each Frm In Forms
If Frm.Name <> "MDIFrm" Then
Unload Frm
Set Frm = Nothing
End If
Next
' Set FSO = Nothing
Unload MDIFrm
Set MDIFrm = Nothing
End Sub