Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup Context Menu problem...

Status
Not open for further replies.

BeegOrange

Programmer
Nov 7, 2002
8
IN
Hello,

I have a menu which gets called like this:

void CCinitView::OnContextMenu(CWnd* pWnd, CPoint point)
{
CMenu menu;
menu.LoadMenu(IDR_POPUP_CRYPTO_MENU);
menu.GetSubMenu(0);
menu.TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}

Unfortunately, when I right click, the menu gets displayed as a thin line! The submenu's get displayed OK when I move the mouse, but the top-level is only shown as a thin line.

In the resource editor, the menu always displays as horizontal, and never saves to be vertical (like a good popup menu should).

How is this problem to be solved??

Thanks in advance!
 
As explained in the MSDN documentation:

CMenu::GetSubMenu
CMenu* GetSubMenu( int nPos ) const;

Return Value

A pointer to a CMenu object whose m_hMenu member contains a handle to the pop-up menu if a pop-up menu exists at the given position; otherwise NULL. If a CMenu object does not exist, then a temporary one is created. The CMenu pointer returned should not be stored.


you should add the following to your function:

CMenu * submenu = menu.GetSubMenu(0);
submenu->TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);

I hope this helps,

Vincent
 
Hello Vincent,

It more or less worked. I learnt a few menu fundamentals on the way. Thanks for the tip!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top