PopMenu 弹出式菜单(变灰,禁用,激活)


    PopMenu 弹出式菜单(变灰,禁用,激活)
void CBallsRaceView::OnContextMenu(CWnd* pWnd, CPoint point)
{
 // TODO: Add your message handler code here
 CMenu menu;
 menu.LoadMenu(IDR_POPMENU);
 //ball0
 if (m_TestBall0_Able)
 {
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball0Wait,MF_ENABLED|MF_BYCOMMAND);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball0Continue,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
 }
 else
 {
  
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball0Wait,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball0Continue,MF_ENABLED|MF_BYCOMMAND);
 }
 //ball1
 if (m_Ball1_Able)
 {
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball1Wait,MF_ENABLED|MF_BYCOMMAND);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball1Continue,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
 }
 else
 {
  
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball1Wait,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball1Continue,MF_ENABLED|MF_BYCOMMAND);
 }
 //ball2
 if (m_Ball2_Able)
 {
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball2Wait,MF_ENABLED|MF_BYCOMMAND);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball2Continue,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
 }
 else
 {
  
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball2Wait,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball2Continue,MF_ENABLED|MF_BYCOMMAND);
 }
 //ball3
 if (m_Ball3_Able)
 {
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball3Wait,MF_ENABLED|MF_BYCOMMAND);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball3Continue,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
 }
 else
 {
  
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball3Wait,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball3Continue,MF_ENABLED|MF_BYCOMMAND);
 }
 //ball4
 if (m_Ball4_Able)
 {
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball4Wait,MF_ENABLED|MF_BYCOMMAND);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball4Continue,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
 }
 else
 {
  
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball4Wait,MF_DISABLED|MF_BYCOMMAND|MF_GRAYED);
  menu.GetSubMenu(0)->EnableMenuItem(ID_Ball4Continue,MF_ENABLED|MF_BYCOMMAND);
 }
 
 CPoint posMouse;
 GetCursorPos(&posMouse);
  //显示菜单
 // ClientToScreen(&posMouse);
// menu.GetSubMenu(0)->EnableMenuItem(ID_Ball0Wait,MF_ENABLED|MF_BYCOMMAND);
// menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
 menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,posMouse.x,posMouse.y,this);
}

你可能感兴趣的:(menu)