[VC] 滑鼠右鍵事件 - 跳出對話框

  • 2237
  • 0
  • 2010-12-25

[VC] 滑鼠右鍵事件 - 跳出對話框

加入OnContextMenu(CWnd* pWnd, CPoint point) 事件

  CMenu menu;
  menu.LoadMenu(IDR_MENU); 
  menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,point.x,point.y, this);

  假設要指定某各區域的話.........

  CRect rect;

  GetDlgItem(IDC_TEST)->GetWindowRect(&rect);

   if(rect.PtInRect(point))
   {

      CMenu menu;
      menu.LoadMenu(IDR_MENU); 
      menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,point.x,point.y, this);       

  .    .................................

   }