我正在使用 C++ 在原始 WinApi 中编写应用程序。我从一开始就编写自己的控件。当鼠标按钮在特定 HWND 之外单击时,我需要获取信息。WinApi 中是否有任何内置机制来执行此类操作,或者我可能需要编写自己的逻辑?
问问题
103 次
1 回答
-1
#define IDM_FILE_NEW 21
#define IDM_FILE_OPEN 44
#define IDM_FILE_QUIT 88
case WM_RBUTTONUP:
{
HNENU hMenu;
POINT point;
point.x = LOWORD(lParam);
point.y = HIWORD(lParam);
hMenu = CreatePopupMenu();
ClientToScreen(hwnd, &point);
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW,
L"&New");
AppendMenuW(hMenu, MF_STRING, IDM_FILE_OPEN,
L"&Open");
AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
AppendMenuW(hMenu, MF_STRING, IDM_FILE_QUIT,
L"&Quit");
TrackPopupMenu(hMenu, TPM_RIGHTBUTTON,
point.x, point.y, 0, hwnd, NULL);
DestroyMenu(hMenu);
}
break;
于 2020-06-03T13:45:13.923 回答