not getting messages
-
I'm trying to add a context menu to a tray icon that appears when a user right clicks on it. I'm not getting any of the "click" messages in the window that is passed in NOTIFYICONDATA. I did notice one thing. I was using SPY++ to see if the parent window existed (it's a 0,0,0,0 invisible window). I right clicked on the window and then clicked properties. As soon as I did the window started receiving messages like crazy. Does anyone know what's going on and what I need to do to fix it? Here's some code snippets
CTrayWindow trayWindow; // CTrayWindow derives publicly from CWnd trayWindow.CreateEx(0, AfxRegisterWndClass(NULL), "Tray Window", WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, 0); ... m_iconData.hWnd = trayWindow.GetSafeHwnd(); // m_iconData is a NOTIFYICONDATA m_iconData.uID = WM_MYMESSAGE; m_iconData.uCallbackMessage = WM_MYMESSAGE; m_iconData.uFlags = NIF_ICON | NIF_MESSAGE; Shell_NotifyIcon(NIM_ADD, &m_iconData);
CTrayWindow is instantiated in my CWinApp::InitInstance() Thanks! -
I'm trying to add a context menu to a tray icon that appears when a user right clicks on it. I'm not getting any of the "click" messages in the window that is passed in NOTIFYICONDATA. I did notice one thing. I was using SPY++ to see if the parent window existed (it's a 0,0,0,0 invisible window). I right clicked on the window and then clicked properties. As soon as I did the window started receiving messages like crazy. Does anyone know what's going on and what I need to do to fix it? Here's some code snippets
CTrayWindow trayWindow; // CTrayWindow derives publicly from CWnd trayWindow.CreateEx(0, AfxRegisterWndClass(NULL), "Tray Window", WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, 0); ... m_iconData.hWnd = trayWindow.GetSafeHwnd(); // m_iconData is a NOTIFYICONDATA m_iconData.uID = WM_MYMESSAGE; m_iconData.uCallbackMessage = WM_MYMESSAGE; m_iconData.uFlags = NIF_ICON | NIF_MESSAGE; Shell_NotifyIcon(NIM_ADD, &m_iconData);
CTrayWindow is instantiated in my CWinApp::InitInstance() Thanks!I remember hearing something about setting the foreground window and posting NULL messages when you are finished with the menu... something like this:
pWnd->SetForegroundWindow();
pMenu->TrackPoupMenu(
TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
point.x, point.y, pWnd, NULL );
pWnd->PostMessage( WM_NULL );Hope this helps, or points you in the right direction somehow...
There are 10 kinds of people - those that get binary and those that don't.