//已验证过

//已验证过 

void CCadersRosterView::OnContextMenu(CWnd* pWnd, CPoint point)

 {

 //右键弹出菜单项

 CMenu m_datamenu; 

m_datamenu.LoadMenu(IDR_DATA);

 CMenu*m_subdatamenu=m_datamenu.GetSubMenu(0); 

CPoint pt; GetCursorPos(&pt); 

ASSERT( m_subdatamenu != NULL );

 POSITION poslist=m_list.GetFirstSelectedItemPosition(); 

if(poslist==NULL) 

{ 

m_subdatamenu->EnableMenuItem(1,MF_GRAYED|MF_BYPOSITION );//MF_BYPOSITION不可少 
m_subdatamenu->EnableMenuItem(2,MF_GRAYED|MF_BYPOSITION );

 m_subdatamenu->EnableMenuItem(3,MF_GRAYED|MF_BYPOSITION );

 m_subdatamenu->EnableMenuItem(4,MF_GRAYED|MF_BYPOSITION ); 

m_subdatamenu->EnableMenuItem(5,MF_GRAYED|MF_BYPOSITION ); 

}

 m_subdatamenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON ,pt.x,pt.y,this); 

m_datamenu.Detach(); 

}
posted on 2011-08-05 21:02  role  阅读(331)  评论(0编辑  收藏  举报