I have added a popup menu to my app, and it is activated with this code:
HMENU contextMenu;
int CALLBACK WinMain(...)
{
HMENU hContext = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_CONTEXT_MENU));
contextMenu = GetSubMenu(hContext, 0);
}
case WM_RBUTTONDOWN:
{
POINT pt;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ClientToScreen(hWndSDL, &pt);
SetForegroundWindow(hWndSDL);
TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, pt.x, pt.y, 0, hWndSDL, NULL);
break;
}
If I have the menu popped up, and then click the window’s title bar, the menu dissappears, but the window still wont respond to any clicks outside the client area of the window.
I set a the KEYUP even for a letter on the keyboard to call ReleaseCapture(), and allows the non-client area of the window to start responding again. But this behavior should be automatic when the menu is dismissed shouldn’t it?
anyone have any ideas?
thanks
Why are you showing your menu in WM_RBUTTONDOWN handler?
It should be WM_CONTEXTMENU instead, and you must keep in mind it may be generated by the keyboard, and contain no coordinates.
Or at least use WM_RBUTTONUP inetead.