代码实现的功能:托盘图片右键弹出MessageBox
加载托盘图标:
memset(&m_trayIcon, 0, sizeof(NOTIFYICONDATA));
m_trayIcon.cbSize = sizeof(NOTIFYICONDATA);
m_trayIcon.hIcon = ::LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LOGO));
m_trayIcon.hWnd = m_hWnd;
lstrcpy(m_trayIcon.szTip, _T("tecare"));
m_trayIcon.uCallbackMessage = WM_USER;
m_trayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
Shell_NotifyIcon(NIM_ADD, &m_trayIcon);
ShowWindow(SW_HIDE);
其中返回的是WM_USER;
右键弹出对话框代码如下:
LRESULT ViewForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,POINT point)
{
LRESULT lRes = 0;
BOOL bHandled = TRUE;
switch (uMsg)
{
case WM_USER:
MessageBox(NULL, _T("hello"), _T("界面"), NULL);
break;
default:
bHandled = FALSE; break;
}
if (bHandled) return lRes;
return Window::HandleMessage(uMsg, wParam, lParam);
}
运行结果为:托盘图标右键能显示出来,但是右键的时候messagebox没有弹出来!!!,加断点的时候 HandleMessage函数没有执行。该如何解决