WM_POWERBROADCAST message not caught in MFC Dlg(WM_POWERBROADCAST 消息未在 MFC Dlg 中捕获)
问题描述
当系统进入睡眠模式时,我尝试捕捉 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_...
}
}
请务必查看 MSDNwParam 值周围的一些特定于操作系统的情况.
Be sure to check MSDN for some OS-specific cases around the wParam values.
这篇关于WM_POWERBROADCAST 消息未在 MFC Dlg 中捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WM_POWERBROADCAST 消息未在 MFC Dlg 中捕获


- 近似搜索的工作原理 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07