Dynamic Menus
-
Hi, I have created a dynamic menu, but now im not sure how to get the menu item to respond when they are clicked on. The items are created by the user at run time. Is there a simple solution to this? Cheers Dor
If you have a menu, if its a popup menu, you can get t ereturn value at the time of the call like this:
int ret = TrackPopupMenuEx(pSub->m_hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, x, y, this->m_hWnd, NULL);
switch (ret)
{
case IDC_COMMAND1:
case IDC_ANOTHER_COMMAND:
}The function returns 0 if the menu was cancelled. If its a top level menu, then I would recommend using a set range of menu iDs e.g. 10000 - 11000. You could them map the command using the ON_COMMAND_RANGE() macro for the message map. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003