Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/03/2005, 18:16
Avatar de xknown
xknown
 
Fecha de Ingreso: diciembre-2004
Ubicación: Cusco - Perú
Mensajes: 2.248
Antigüedad: 19 años, 4 meses
Puntos: 7
La idea es reconocer quien envía el mensaje para cerrar la ventana, si es resultado de la acción del usuario o del sistema operativo. Aquí hay una forma de hacerlo:
Código:
Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Dim O As System.Diagnostics.StackTrace = New System.Diagnostics.StackTrace(True)
        Dim F As System.Diagnostics.StackFrame

        F = O.GetFrame(7)

        Select Case F.GetMethod.Name.ToString
            Case "SendMessage"
                'MsgBox("Closing because of call in code.")
                ntiTray.Visible = False
            Case "CallWindowProc"
                'MsgBox("Closing because of system menu click.")
                e.Cancel = True
                Me.Hide()
            Case "DispatchMessageW"
                'MsgBox("Closing because of Task Manager.")
                ntiTray.Visible = False
            Case Else
                'MsgBox("Don't Know why I'm closing!!??")
                ntiTray.Visible = False
        End Select
    End Sub
Referencia: http://vbcity.com/forums/topic.asp?tid=12221&#RID84157
__________________
Alex Concha
Buayacorp - Programación y Diseño