假如:有两种设置
1,设置类型A
2,设置类型B
类型A和类型B都需要一个对话框:
1,A对话框
2,B对话框
将A和B放在一个Menu中
步骤:
具体Menu的操作:
http://www.lingchenliang.com/post/1876.html
CMenu类:
https://blog.youkuaiyun.com/alexander_frank/article/details/52126660
CMenu *pMenu = new CMenu();
ASSERT(pMenu != NULL);
BOOL bRet = pMenu->LoadMenu(IDR_MENU_SET);
if (bRet == FALSE)
{
delete pMenu;
return;
}
CMenu* pSubMenu = pMenu->GetSubMenu(0);
ASSERT(pSubMenu != NULL);
UINT nID = pSubMenu->GetMenuItemID(0);
pSubMenu->ModifyMenu(0, MF_BYPOSITION , nID , _T("设置A"));
nID = pSubMenu->GetMenuItemID(1);
pSubMenu->ModifyMenu(1, MF_BYPOSITION , nID , _T("设置B"));
需要在设置旁边显示设置菜单:主要设置属性问题
摘自msdn的例子:
// The code fragment shows how to get the File menu from the
// application window and displays it as a floating popup menu
// when the right mouse button is clicked in view.
// CMdiView is a CView-derived class.
void CMdiView::OnRButtonDown(UINT nFlags, CPoint point)
{
CView::OnRButtonDown(nFlags, point);
CMenu* menu_bar = AfxGetMainWnd()->GetMenu();
CMenu* file_menu = menu_bar->GetSubMenu(0);
ASSERT(file_menu);
ClientToScreen(&point);
file_menu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y, this);
}
if (nCmd == ID_SET_A)
{
ADlg dlg;
if (dlg.DoModal() == IDOK) {
}
}
else if (nCmd == ID_SET_B)
{
BDlg dlg;
if(){
}
}
delete pMenu;