我正在使用C ++在原始WinApi中编写应用程序。我从开始写自己的控件。当鼠标按钮在特定HWND之外单击时,我需要获取信息。在WinApi中是否有任何构建机制来执行此类操作,或者我需要编写自己的逻辑?
答案 0 :(得分:-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;