Floating Pop-Up Menus是在用户接口设计中最新倾向之一,就是右击出来个菜单供用户选择的那种。
  1. Use the menu editor to insert a new, empty menu in your project's resource file.
  2. Type some characters in the left top-level item, and then add your menu items in the resulting pop-up menu.
  3. Use ClassWizard to add a WM_CONTEXTMENU message handler in your view class or in some other window class that receives mouse-click messages. Code the handler as shown below.
    void CMyView::OnContextMenu(CWnd *pWnd, CPoint point)
        CMenu menu;
            ->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
            point.x, point.y, this);
    You can use ClassWizard to map the floating menu's command IDs the same way you would map the frame menu's command IDs.