I would like to implement a context menu inside a dialog box. I created a "clear" menu (no caption) using Resource Editor. Note that I create an entirely new menu item like IDR_MAINFRAME (mine is IRD_CONTEXTMENU1. Inside the dialog box, I added a message for right-click. Here is what the code looks like.
// Program crashes at this point.
CMenu *pContextMenu = mPopupMenu.GetSubMenu(0);
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY,
mPointCurrent.x, mPointCurrent.y, GetActiveWindow(), NULL);
The code above does not work. The program crashes when I right-click inside the dialog box. Is the code above for a view class only? Is there a different and corrent way to implement a context menu inside a dialog box?