winapi - how to enable popup-menu to communicate with WM_MENUCOMMAND instead of WM_COMMAND? -
what read menu must have menuinfo.dwstyle flag set mns_notifybypos, did is:
menuinfo menuinfo; memset(&menuinfo,0, sizeof(menuinfo)); menuinfo.cbsize = sizeof(menuinfo); hmenu hpopupmenu = createpopupmenu(); getmenuinfo(hpopupmenu, &menuinfo); menuinfo.dwstyle |= mns_notifybypos; setmenuinfo(hpopupmenu, &menuinfo);
and next proceed adding items:
insertmenu(hpopupmenu, pos, mf_byposition, id , "do command");
next track it:
trackpopupmenu(hpopupmenu, tpm_centeralign | tpm_returncmd, cursorpos.x, cursorpos.y, 0, hwnd, null);
but has no effect, compiles without error clicking event till send wm_command
you need set fmask fellow member of menuinfo
construction tell scheme fields want set/get.
e.g.
menuinfo.fmask = mim_style; getmenuinfo(hpopupmenu, &menuinfo); menuinfo.dwstyle |= mns_notifybypos; setmenuinfo(hpopupmenu, &menuinfo);
also note docs say:
mns_notifybypos menu header style , has no effect when applied individual sub menus.
so possible won't work anyway popup menu.
winapi menu
No comments:
Post a Comment