我创建了一个这样的上下文菜单:
资源文件:
IDR_CONTEXT MENU
BEGIN
POPUP ""
BEGIN
MENUITEM "Add &last", ID_ADDLAST
MENUITEM "Add &before", ID_ADDBEFORE
MENUITEM "Add &after", ID_ADDAFTER
MENUITEM "&Remove", ID_REMOVE
END
END
窗口程序:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_RBUTTONDOWN:
{
POINT cursor;
GetCursorPos(&cursor);
TrackPopupMenu((HMENU) GetSubMenu(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXT)), 0), TPM_LEFTALIGN, cursor.x, cursor.y, 0, hWnd, NULL);
}
break;
}
}
但这不允许我右键单击上下文菜单中的项目。我只能点击它们...... 如何解决这个问题?