CMenu创建弹出菜单

      LPPOINT lpoint = new tagPOINT;
        ::GetCursorPos(lpoint);//得到鼠标位置
        CMenu menu;
        menu.CreatePopupMenu();//声明一个弹出式菜单
        menu.AppendMenu(MF_STRING, MID_EXIT, "退出");
        //确定弹出式菜单的位置
        SetForegroundWindow();  //点屏幕其他地方,菜单会消失
        menu.TrackPopupMenu(TPM_LEFTALIGN, lpoint->x, lpoint->y, this);
        //资源回收
        HMENU hmenu = menu.Detach();
        menu.DestroyMenu();
        delete lpoint;

你可能感兴趣的:(CMenu创建弹出菜单)