How can I popup a context menu from inside a dialog box?

chual
chual used Ask the Experts™
on
I am trying to bring up a popup menu on right clicking on a dialog box. The following code works fine at all other place(CViews, list boxes, edit boxes...), but not when right clicking on the dialog box. When used inside a dialog box, the right click only bring up a little tiny box at the size of a character(in width). Does anyone know what else I have to do to get it work?
Thanks.

CMenu menu;
VERIFY(menu.LoadMenu(IDR_MY_MENU));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
               point.x, point.y, this);
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi! you make all right for poping up menu but in the las call missed object to popup
must be:

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
              point.x, point.y, this);

Commented:
If you want to display the popup menu over your Dialog under the mouse pointer, add the following line:

ClientToScreen(&point);
//Befor this line
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
             point.x, point.y, this);


Good luck

Commented:
Thanks Nass89 you are the cream in my coffee.  I had a Popup menu that keep floating further and further away each time the application was started.  You Screen to Client was what turned the trick.  I know that this is an old thread but I needed to say something.  Nass89 I do need to compensate you 100 points I feel... It was your contribution that make this work.  I hope your are still out there.  
graber

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial