vbAccelerator - Contents of code file: mMain.bas

Attribute VB_Name = "mMain"
Option Explicit

Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Declare Function SetErrorMode Lib "kernel32" (ByVal wMode As Long) As
 Long
Private Const SEM_FAILCRITICALERRORS = &H1
Private Const SEM_NOGPFAULTERRORBOX = &H2
Private Const SEM_NOOPENFILEERRORBOX = &H8000

Private m_bInIDE As Boolean

' ----------------------------------------------
' START: Added to allow testing
Private m_bUnloadClean As Boolean

Public Property Get UnloadClean() As Boolean
   UnloadClean = m_bUnloadClean
End Property
Public Property Let UnloadClean(ByVal bState As Boolean)
   m_bUnloadClean = bState
   Dim frm As Form1
   For Each frm In Forms
      frm.chkUnloader.Value = Abs(bState)
   Next
End Property
' END: Added to allow testing
' ----------------------------------------------

Public Sub Main()
   
   InitCommonControls
   
   Dim f As New Form1
   f.Show
   Set f = Nothing
   
End Sub

Public Sub UnloadApp()
   If Not InIDE() Then
      ' ----------------------------------------------
      ' START: Added to allow testing
      If Not (m_bUnloadClean) Then
         Exit Sub
      End If
      MsgBox "UnloadApp Called"
      ' END: Added to allow testing
      ' ----------------------------------------------
      
      SetErrorMode SEM_NOGPFAULTERRORBOX
      
   End If
End Sub

Public Property Get InIDE() As Boolean
   Debug.Assert (IsInIDE())
   InIDE = m_bInIDE
End Property

Private Function IsInIDE() As Boolean
   m_bInIDE = True
   IsInIDE = m_bInIDE
End Function