can someone please tell me what i missed?
thx in advance... -.rhavin;)
void CListCtrl::OnRButtonDown(UINT nFlags, CPoint point) {
CMenu menu;
ClientToScreen(&point);
menu.CreateMenu();
menu.InsertMenu(0,MF_BYCOMMAND,1,"test1");
menu.InsertMenu(0,MF_SEPARATOR,2,"");
menu.InsertMenu(0,MF_BYCOMMAND,3,"test2");
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN, point.x, point.y,
this);
}
Tom
".rhavin grobert" <cl...@yahoo.de> wrote in message
news:1176996568.1...@o5g2000hsb.googlegroups.com...
Here's a little example that works.
CMenu Menu;
Menu.CreatePopupMenu();
Menu.AppendMenu(0, IDM_ZOOM, "Zoom");
Menu.AppendMenu(MF_SEPARATOR, 0, "");
Menu.AppendMenu(0, IDM_CANCEL_POPUP, "Cancel");
GetParentFrame()->ActivateFrame();
ClientToScreen(&point);
Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
point.x-8, point.y-8,
AfxGetMainWnd());
--
Scott McPhillips [VC++ MVP]
No, it got access violation;-)
here is what happens (i added UINT B to see the results in debug....)
CMenu menu;
UINT B = 2;
ClientToScreen(&point);
B = menu.CreateMenu(); // B is 1
B = menu.InsertMenu(-1,MF_BYCOMMAND,1,"test1"); // B is 1
B = menu.InsertMenu(-1,MF_SEPARATOR,2,""); // B is 1
B = menu.InsertMenu(-1,MF_BYCOMMAND,3,"test2"); // B is 1
B = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN, point.x,
point.y, this);
// B is 1, menu is displayed with width ~ 0;
CMenu Menu;
B = Menu.CreatePopupMenu(); // B is 1
B = Menu.AppendMenu(0, 3, "Zoom"); // B is 1
B = Menu.AppendMenu(MF_SEPARATOR, 0, ""); // B is 1
B = Menu.AppendMenu(0, 4, "Cancel"); // B is 1
CFrameWnd* pFW = GetParentFrame(); // pFW is 0!;
if (pFW != 0) {pFW->ActivateFrame();}
ClientToScreen(&point);
B = Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x-8,
point.y-8, AfxGetMainWnd());
// menu is displayed correctly "somewhere"
Tom
".rhavin grobert" <cl...@yahoo.de> wrote in message
news:1177001997....@y80g2000hsf.googlegroups.com...
jmarc..
".rhavin grobert" <cl...@yahoo.de> wrote in message
news:1176996568.1...@o5g2000hsb.googlegroups.com...
Victor
"jmarc" <jm...@incursion-voyages.com> wrote in message
news:e76Wh.10917$VF5.7447@edtnps82...