المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Popmenu in View class



C++ Programming
11-26-2009, 02:30 AM
Hi,
I created one popup menu and loaded in CFaceplate.cpp(dialog class)
void CFacePlate::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu mnuPopup;
mnuPopup.LoadMenu(IDR_FPMENU);
CRect rBarRect;
rBarRect.left = rBarRect.top = 0;
rBarRect.right = 1000;rBarRect.bottom = 300;
// Get a pointer to the first item of the menu
CMenu *mnuPopupMenu = mnuPopup.GetSubMenu(0);
ASSERT(mnuPopupMenu);
if( rBarRect.PtInRect(point) )
mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWnd);

}
And this IDR_MENU contains four menu.I written code for this menu in CMAinframe as
void CMainFrame::OnUpdateFpgroup(CCmdUI* pCmdUI)
{
((CMainFrame *)AfxGetMainWnd())->SendMessage(WM_COMMAND,ID_GROUPVIEW,NULL);
}
It works fine.
But i used this same concept in CTuningView(View class).I can get the popup menu,but when i press the menu-Fpgroup,it doesnot go to CMainframe fucntion.I checked by placing F9.
Pls help me.

Anu