C
Clemente
Hi,
We have a VB.Net application that is sleeping until it receives a
logoff/shutdown event. We want the application running on Vista and
XP.
When the application receives those events it has to show a message
box, so the user can answer Yes or No, and then let the logoff/
shutdown process continues.
We are doing this in VB.Net listening to WM_QUERYENDSESSION message.
We are having the following problems:
.. - It doesnt work in Vista.
- In XP, when the application receives the WM_QUERYENDSESSION
message it shows the System End Task window for this application,
before showing the message box we want.
We are using this VB . Net code:
---------------------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
Private Shared systemShutdown As Boolean = False
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'MessageBox.Show("queryendsession: this is a logoff,
shutdown, or reboot")
systemShutdown = True
End If
' If this is WM_QUERYENDSESSION, the closing event should be
raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc
-------------------------
Private Sub frmMsg_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (systemShutdown) Then
' Reset the variable because the user might cancel the
shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes =
MessageBox.Show("My application", "Abort logoff?",
MessageBoxButtons.YesNo)) Then
e.Cancel = True
Else
e.Cancel = False
End If
End If
End Sub
-----------------------
Why this behaviour? Any ideas?
TIA,
Clemente
Portugal
We have a VB.Net application that is sleeping until it receives a
logoff/shutdown event. We want the application running on Vista and
XP.
When the application receives those events it has to show a message
box, so the user can answer Yes or No, and then let the logoff/
shutdown process continues.
We are doing this in VB.Net listening to WM_QUERYENDSESSION message.
We are having the following problems:
.. - It doesnt work in Vista.
- In XP, when the application receives the WM_QUERYENDSESSION
message it shows the System End Task window for this application,
before showing the message box we want.
We are using this VB . Net code:
---------------------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
Private Shared systemShutdown As Boolean = False
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'MessageBox.Show("queryendsession: this is a logoff,
shutdown, or reboot")
systemShutdown = True
End If
' If this is WM_QUERYENDSESSION, the closing event should be
raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc
-------------------------
Private Sub frmMsg_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (systemShutdown) Then
' Reset the variable because the user might cancel the
shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes =
MessageBox.Show("My application", "Abort logoff?",
MessageBoxButtons.YesNo)) Then
e.Cancel = True
Else
e.Cancel = False
End If
End If
End Sub
-----------------------
Why this behaviour? Any ideas?
TIA,
Clemente
Portugal