I am trying to implement a context menu when the MFC Dialog is clicked. I can get the menu up, but cannot get the individual sub-menu items in the menu to do anything when clicked. I used the wizard to add an event handler for the sub-menu items. I checked to make sure that the message map had entries for clicking in the sub-menu items. Clicking on the sub-menu items never hit the break points I placed in the generated functions I'm currently stuck at this point. Any help would be appreciated.,
To open the menu, i did the following:
<code>
CPoint mPointCurrent;
::GetCursorPos(&mPointCurrent);
CMenu mPopupMenu;
mPopupMenu.LoadMenu(IDR_MAP_CONTEXT);
To create the event handlers for the individual sub-menu items, I right clicked the sub-menu item in the resource editor and selected add event handler. I then chose the dialog class that i wanted the event handler to be added to (the same dial that is opening the menu). It added a ON_COMMAND and ON_UPDATE_COMMAND_UI event handlers in the dialog class.
In what class did you implement the code you have posted?
What was the your goal to pass in the ::GetActiveWindow API as the forth parameter of TrackPopupMenu?
Besides that ::GetActiveWindow() return value is HWND while TrackPopupMenu requires CWnd*, it is also not clear what was the active window while TrackPopupMenu has been called.
How and where (in what class) did you implement the message handlers for this menu items?
Start Microsoft Visual C++ MFC Application named ControlContext
Create it as Dialog Box without the AboutBox
Set the Dialog Title to Context-Sensitive Menu on Controls
Add a button to dialog box. Change its ID to IDC_SUBMIT_BTN and its Caption to Submit
Add a check box to the dialog box. Change its ID to IDC_APPROVED_CHK and its Caption to Approved:
Bookmarks