第六章 关于POP_UP MENU

来源:互联网 发布:淘宝怎么交易游戏账号 编辑:程序博客网 时间:2024/06/05 21:03

经过一番思考,在VS2005 里里应该没有POP_UP MENU控件,以下是两种实现方法(网上找的)

 

 

void CMy61popView::OnRButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 

/*CMenu menu;
 menu.LoadMenu(IDR_MENU1);
 CMenu *pmenu = menu.GetSubMenu(0);
 ClientToScreen(&point);
 pmenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);*/

//TPM_LEFTALIGN   Positions the pop-up menu so that its left side is aligned with the coordinate specified byx

 

  CMenu menu;
  menu.LoadMenu(IDR_MENU1); //载入事先定义的选单
  CMenu *pMenu=menu.GetSubMenu(0);
  CPoint pos;
  GetCursorPos(&pos);
  pMenu->TrackPopupMenu(TPM_LEFTALIGN  |  TPM_RIGHTBUTTON,  pos.x+50,   pos.y-20,   AfxGetMainWnd()  );

 CView::OnRButtonDown(nFlags, point);
}