You created an icon in system notification area, and want it to responding your mouse click.Usually, you want your application’s menu can be popped up after you clicked on it, generally, right clicked on it.

According to MSDN, you wrote down following codes,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
case WM_RBUTTONDOWN:
{
...
SetForegroundWindow(hDlg);
// Display the menu
TrackPopupMenu( hSubMenu,
TPM_RIGHTBUTTON,
pt.x,
pt.y,
0,
hDlg,
NULL);
PostMessage(hDlg, WM_NULL, 0, 0);
...
}

Right, it works. But why you got taskbar menu popping up again and again after your clicked on your own icon? What’s wrong with your code? Is that a bug of Windows shell itself? You can think so, but you still need a work-around.

Very fortunately, the key is very very simple. You only need change WM_RBUTTONDOWN to WM_RBUTTONUP.

(If your application stuck in WM_RBUTTONDOWN, complain it to Microsoft.)

Comments