/constants needed, form level
private const System.Int32 WM_QUERYENDSESSION = 0x11;
private const System.Int32 WM_CANCELMODE = 0x1f;
//the sub to intercept the windows messages
protected override void WndProc(ref Message ex)
{
if (ex.Msg == WM_QUERYENDSESSION)
{
//cancel the message
Message MyMsg = new Message();
MyMsg.Msg = WM_CANCELMODE;
base.WndProc(MyMsg);
}
else
{
//send the message as normal
base.WndProc(ex);
}
}
小中中的學習筆記
//constants needed, form level
private const System.Int32 WM_QUERYENDSESSION = 0x11;
private const System.Int32 WM_CANCELMODE = 0x1f;
//the sub to intercept the windows messages
protected overridevoid WndProc(ref Message ex)
{
if (ex.Msg == WM_QUERYENDSESSION)
{
//cancel the message
Message MyMsg = new Message();
MyMsg.Msg = WM_CANCELMODE;
base.WndProc(ref MyMsg);
}
else
{
//send the message as normal
base.WndProc(ref ex);
}
}
vs2008要修改下就可以了
- 已标记为答案ybgjj2009 2010年8月3日 7:36
-
全部回复
-
你可以使窗体类继承Control.WndProc,然后响应WM_QUERYENDSESSION事件,比如
'constants needed, form level
Private Const WM_QUERYENDSESSION As System.Int32 = &H11
Private Const WM_CANCELMODE AsSystem.Int32 = &H1F
'the sub to intercept the windows messages
Protected Overrides Sub WndProc(ByRef ex As Message)
If ex.Msg = WM_QUERYENDSESSION Then
'cancel the message
Dim MyMsg As New Message
MyMsg.Msg = WM_CANCELMODE
MyBase.WndProc(MyMsg)
Else
'send the message as normal
MyBase.WndProc(ex)
End If
End Sub
-
你可以使窗体类继承Control.WndProc,然后响应WM_QUERYENDSESSION事件,比如
'constants needed, form level
Private Const WM_QUERYENDSESSION As System.Int32 = &H11
Private Const WM_CANCELMODE As System.Int32 = &H1F
'the sub to intercept the windows messages
Protected Overrides Sub WndProc(ByRef ex As Message)
If ex.Msg = WM_QUERYENDSESSION Then
'cancel the message
Dim MyMsg As New Message
MyMsg.Msg = WM_CANCELMODE
MyBase.WndProc(MyMsg)
Else
'send the message as normal
MyBase.WndProc(ex)
End If
End Sub
vb的代码.........
-
//constants needed, form level
private constSystem.Int32 WM_QUERYENDSESSION = 0x11;
private const System.Int32 WM_CANCELMODE = 0x1f;
//the sub to intercept the windows messages
protected override void WndProc(ref Message ex)
{
if (ex.Msg == WM_QUERYENDSESSION)
{
//cancel the message
Message MyMsg = new Message();
MyMsg.Msg = WM_CANCELMODE;
base.WndProc(MyMsg);
}
else
{
//send the message as normal
base.WndProc(ex);
}
}
小中中的學習筆記
-
//constants needed, form level
private const System.Int32 WM_QUERYENDSESSION = 0x11;
private const System.Int32 WM_CANCELMODE = 0x1f;
//the sub to intercept the windows messages
protected override void WndProc(ref Message ex)
{
if (ex.Msg == WM_QUERYENDSESSION)
{
//cancel the message
Message MyMsg = new Message();
MyMsg.Msg = WM_CANCELMODE;
base.WndProc(MyMsg);
}
else
{
//send the message as normal
base.WndProc(ex);
}
}
小中中的學習筆記
//constants needed, form level
private const System.Int32 WM_QUERYENDSESSION = 0x11;
private const System.Int32 WM_CANCELMODE = 0x1f;
//the sub to intercept the windows messages
protected overridevoid WndProc(ref Message ex)
{
if (ex.Msg == WM_QUERYENDSESSION)
{
//cancel the message
Message MyMsg = new Message();
MyMsg.Msg = WM_CANCELMODE;
base.WndProc(ref MyMsg);
}
else
{
//send the message as normal
base.WndProc(ref ex);
}
}
vs2008要修改下就可以了