End Function

Private Function ThrowError(ByVal lErr As Long)
Dim sMsg As String
   If lErr = 1 Then
      ' fatal
      Destroy
      gErr 2
   Else
      gErr 3
   End If
End Function
Private Function Destroy()
   If m_hBmpOld &lt;&gt; 0 Then
      SelectObject m_hDC, m_hBmpOld
      m_hBmpOld = 0
   End If
   If m_hBmp &lt;&gt; 0 Then
      DeleteObject m_hBmp
      m_hBmp = 0
   End If
   If m_hDC &lt;&gt; 0 Then
      DeleteDC m_hDC
      m_hDC = 0
   End If
   
End Function
Public Function ExtractBitm