Popup Menu not popping up ;(
Hi, all. This is straight from the book.
It compiles fine, but when I run it and click the RMB, no popup menu appears. What gives?
CMenu * g_pmenuContext;
CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
g_pmenuContext = new CMenu();
if (!g_pmenuContext) return -1;
BOOL bSuccess = g_pmenuContext->LoadMenu(IDR_MENU1);
if (!bSuccess) return -1;
...
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
ClientToScreen(&point);
CMenu * psubmenu = g_pmenuContext->GetSubMenu(1);
psubmenu->TrackPopupMenu(TPM_LEFTALIGN /TPM_RIGHTBUTTON, point.x, point.y, this);
CFrameWnd::OnRButtonDown(nFlags, point);
}
Thanks
Hi!
You need to handle the WM_CONTEXTMENU message.
*Sparkle*
Edited by - Sparkle on 4/12/00 5:24:44 AM
You need to handle the WM_CONTEXTMENU message.
void CMyView::OnContextMenu(CWnd* pWnd, CPoint point){ CMenu menu; menu.LoadMenu(IDR_MYFLOATINGMENU); menu.GetSubMenu(0)->TrackPopupMenu(.......);}
*Sparkle*
Edited by - Sparkle on 4/12/00 5:24:44 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement