MFC Dlg中未捕获WM_POWERBROADCAST消息 [英] WM_POWERBROADCAST message not caught in MFC Dlg
本文介绍了MFC Dlg中未捕获WM_POWERBROADCAST消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当系统进入睡眠模式时,我尝试捕获WM_POWERBROADCAST消息.
I try to catch WM_POWERBROADCAST message when the system goes into sleep mode.
我在做:
BOOL CPowManApp::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_POWERBROADCAST || pMsg->message == WM_POWER)
{
CString strMessage;
strMessage.Format(_T("%d WM_POWERB%s wParam %x lParam %x"),
pMsg->time,
pMsg->message == WM_POWER?_T(""):_T("BRAODCAST"),
pMsg->wParam,
pMsg->lParam);
OutputDebugString(strMessage);
}
return CWinApp::PreTranslateMessage(pMsg);
}
它根本不起作用.同时,一个win32应用程序也可以正常工作.我试图将消息处理程序徒劳地放在Dlg类中.
It simply doesn't work. Meanwhile a win32 app works just fine. I tried to put the message handler in the Dlg class in vain.
我正在使用VS6.0构建应用程序.我在哪里错了?
I'm building the app with VS6.0. Where am I wrong?
推荐答案
在您的消息图中
ON_MESSAGE( WM_POWERBROADCAST, OnPowerBroadcast )
实施
LRESULT CDialogDlg::OnPowerBroadcast(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case PBT_...
}
}
请务必检查 MSDN 围绕wParam值的某些特定于操作系统的情况.
Be sure to check MSDN for some OS-specific cases around the wParam values.
这篇关于MFC Dlg中未捕获WM_POWERBROADCAST消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文