C++技巧:右鍵彈出菜單

字號:

void CLeftView::OnRButtonDown(UINT nFlags, CPoint point)
    {
    // TODO: Add your message handler code here and/or call default
    CTreeView::OnRButtonDown(nFlags, point);
    CMenu PopMenu;
    CMenu *pMenu;
    CPoint pt;
    pt= point;
    PopMenu.LoadMenu(IDR_EDIT); //菜單ID
    ClientToScreen(&pt);
    pMenu = PopMenu.GetSubMenu(0);
    pMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,
    pt.x,pt.y,this);
    }