EnableMenuItemにて状態を設定します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
CWnd* pWnd = AfxGetMainWnd(); CMenu* pMenu = pWnd->GetMenu(); int MenuCount = pMenu->GetMenuItemCount(); for(int i=0; i<MenuCount; i++){ CString str; pMenu->GetMenuString(i, str, MF_BYPOSITION); if("TEST"== str.Left(MenuName.GetLength())){ pMenu->EnableMenuItem(i, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); pWnd->DrawMenuBar(); } } |