我用BCG界面开发包做了个小东西,不过我的右键菜单好象没关联上,显示为灰色,处理函数已写,请高手指教啊,第一次用BCG,先谢了!

解决方案 »

  1.   

    用ClassWizard,找到菜单的ID,然后选择一个处理消息的类,添加一个消息处理函数就行拉
      

  2.   

    呵呵,在BCG下好象不太一样啊,我看见它自带的例子里面根本没消息处理函数,却能显示出菜单来,好奇怪
      

  3.   

    // 在头文件声明
    CMenu m_menu;
    // 在cpp初始化函数里
    VERIFY(m_menu.LoadMenu(IDR_MENU_GROUP));
    // 在OnContextMenu消息响应函数里
    CMenu *pPopupMenu = m_menu.GetSubMenu(0);
    ASSERT(pPopupMenu != NULL);
    AfxGetApp()->GetContextMenuManager()->ShowPopupMenu(pPopupMenu->GetSafeHmenu(), 
    point.x, point.y, this, TRUE);
      

  4.   

    void COutputList::OnContextMenu(CWnd* pWnd, CPoint point) 
    {
       CMenu menu;
       menu.LoadMenu(IDR_POPUP_OUTPUT);   CMenu* pSumMenu = menu.GetSubMenu(0);   if (AfxGetMainWnd()->IsKindOf(RUNTIME_CLASS(CBCGPMDIFrameWnd)))
       {
       CBCGPPopupMenu* pPopupMenu = new CBCGPPopupMenu;    if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
             return;      ((CBCGPMDIFrameWnd*)AfxGetMainWnd())->OnShowPopupMenu (pPopupMenu);
          UpdateDialogControls(this, FALSE);
       }   SetFocus ();
    }
      

  5.   

    我要实现的菜单是在CWorkspaceBar中,一共有三个CImageList,也就是三个菜单,菜单能显示出来,不过处理函数好象没关联上,点了也没反映
      

  6.   

    我的系统也是跟四楼一样用的.
    CMenu menu;
    menu.LoadMenu(IDR_xxxxx);
    CMenu* pPopupMenu = menu.GetSubMenu(0);
    theApp.GetContextMenuManager()->ShowPopupMenu(pPopupMenu->GetSafeHmenu(),point.x,point.y,this);
    可以正常弹出右键菜单.
      

  7.   

    BEGIN_MESSAGE_MAP(CPlaneTreeWnd, CTreeCtrl)
    //{{AFX_MSG_MAP(CPlaneTreeWnd)
    ON_COMMAND(ID_MNADDPLANE, OnMnAddPlane)
    ON_COMMAND(ID_MNDELETEPLANE, OnMnDeletePlane)
    ON_COMMAND(ID_MNMODIFYPLANE, OnMnModifyPlane)
    //}}AFX_MSG_MAPEND_MESSAGE_MAP()
    处理函数
    void CPlaneTreeWnd::OnMnAddPlane() 
    {
    // TODO: Add your command handler code here
    AfxMessageBox("测试的!");
    可以弹出菜单,但是单击没反映

    }
      

  8.   

    void CWorkspaceBar::OnContextMenu(CWnd* pWnd, CPoint point) 
    {
    int iActiveTab = m_wndTabs.GetActiveTab ();
    if (iActiveTab < 0)
    {
    return;
    } CTreeCtrl* pWndTree = (CTreeCtrl*) m_wndTabs.GetActiveWnd ();
    ASSERT_VALID (pWndTree); if (point != CPoint (-1, -1))
    {
    //---------------------
    // Select clicked item:
    //---------------------
    CPoint ptTree = point;
    pWndTree->ScreenToClient (&ptTree); HTREEITEM hTreeItem = pWndTree->HitTest (ptTree);
    if (hTreeItem != NULL)
    {
    pWndTree->SelectItem (hTreeItem);
    }
    } UINT uiMenuResId = 0;
    switch (iActiveTab)
    {
    case 0:
    uiMenuResId = IDR_PLANEMENU;
    break; case 1:
    // Example: uiMenuResId = IDR_POPUP_RESOURCE_VIEW;
    break; case 2:
    // Example: uiMenuResId = IDR_POPUP_FILE_VIEW;
    break; default:
    ASSERT (FALSE);
    return;
    } if (uiMenuResId != 0)
    {
    pWndTree->SetFocus ();
    theApp.ShowPopupMenu (uiMenuResId, point, AfxGetMainWnd ());
    }}
      

  9.   

    有用过BCG的高手指教下啊,急!!
      

  10.   


    CTreeCtrl* pWndTree = (CTreeCtrl*) m_wndTabs.GetActiveWnd ();
    改为:
    CPlaneTreeWnd* pWndTree = (CPlaneTreeWnd*) m_wndTabs.GetActiveWnd ();