OnContextMenu() not working in view class

Posted by Anu on Stack Overflow See other posts from Stack Overflow or by Anu
Published on 2010-04-02T06:54:51Z Indexed on 2010/04/02 8:43 UTC
Read the original article Hit count: 331

Filed under:
|

Hi, i have a popup menu for contextmenu.And i wrote the function for each menu in CMainframe. I have OnContextMenu() in each view class and in one dialog class.Its works fine in Dialog class.But not in View class.Codings are below: CMainframe funciton:

void CMainFrame::OnUpdateFptrend(CCmdUI* pCmdUI) 
{   
((CMainFrame *)AfxGetMainWnd())->SendMessage(WM_COMMAND,ID_TRENDVIEW,NULL); 
}

void CMainFrame::OnUpdateFptuning(CCmdUI* pCmdUI) 
{       
((CMainFrame *)AfxGetMainWnd())->SendMessageWM_COMMAND,ID_TUNINGVIEW,NULL); 
}

Dialog class Contextmenu:

void CFacePlate::OnContextMenu(CWnd* pWnd, CPoint point) 
{   
    CMenu mnuPopup;
    mnuPopup.LoadMenu(IDR_FPMENU);
    CRect rBarRect;
        rBarRect.left = rBarRect.top = 0;
        rBarRect.right = 1000;rBarRect.bottom = 300;    
    CMenu *mnuPopupMenu = mnuPopup.GetSubMenu(0);
    ASSERT(mnuPopupMenu);   
    if( rBarRect.PtInRect(point) ) 
        mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);  
}

View class:

void CGroupView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
    CMenu mnuPopup;
    mnuPopup.LoadMenu(IDR_FPMENU);

    CRect rBarRect;
        rBarRect.left = rBarRect.top = 0;
        rBarRect.right = 1150;rBarRect.bottom = 390;

    CMenu *mnuPopupMenu = mnuPopup.GetSubMenu(0);
    ASSERT(mnuPopupMenu);   

    if( rBarRect.PtInRect(point) )
        mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);      
}

When i press popup menu from Faceplate(Dialogclass),it goes to Mainframe function.At the same time when i press menu from any view class,it doesnot go to Mainframe function.Why its like that?

© Stack Overflow or respective owner

Related posts about mfc

Related posts about contextmenu