The following code fragment shows how to make a pop-up menu appear when the user double-clicks mouse button 2 anywhere in the parent window. The menu is positioned with the mouse pointer located on the item having the IDM_OPEN identifier and is constrained horizontally and vertically. Then, the user can select an item from the pop-up menu using mouse button 2.
#define ID_MENU_RESOURCE 110 #define IDM_OPEN 120 HWND hwndFrame; MRESULT ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndMenu; BOOL fSuccess; switch (msg) { . . /* Process other messages. */ . case WM_BUTTON2DBLCLK: hwndMenu = WinLoadMenu(hwnd, (HMODULE) NULL, ID_MENU_RESOURCE); fSuccess = WinPopupMenu(hwnd, hwndFrame, hwndMenu, 20, 50, IDM_OPEN, PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2); . . .