Kontextmenü erzeugen
-
Ich wollte mir ein einfaches Kontextmenü für den Rechtsklick auf meinen
Dialog erzeugen.Das geht aber irgendwie nur, wenn ich auch im Dialog selbst das
Menü IDR_MENU1 zuweise. Dabei soll das Menü doch NUR über den
Rechtsklick zu erreichen sein.CMenu *m_lMenu; CPoint m_pPoint; m_pPoint = point; //ClientToScreen(&m_pPoint); m_lMenu=GetMenu(); m_lMenu=m_lMenu->GetSubMenu(0); m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON,m_pPoint.x,m_pPoint.y,this,NULL);
-
Du darfst es halt nicht vonm Dialog holen (GetMenu) wenn Du es da nicht haben willst!
Verwende halt "LoadMenu" oder "CMenu::LoadMenu"...
-
Ah stimmt. So etwa:
CMenu myMenu; if (myMenu.LoadMenu(IDR_MENU1)) { CPoint myPoint; CMenu* pPopup = myMenu.GetSubMenu(0); ASSERT(pPopup != NULL); GetCursorPos(&myPoint); SetForegroundWindow(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, myPoint.x, myPoint.y, this); }