// TODO: Add your command handler code here CWnd* pMain = AfxGetMainWnd(); // The main window _can_ be NULL, so this code // does not ASSERT and actually tests. if (pMain != NULL) { // Get the main window's menu. CMenu* pMenu = pMain->GetMenu(); // If there is a menu and it has items, we will // delete the first one. if (pMenu != NULL && pMenu->GetMenuItemCount() > 0) { if (MF_UNCHECKED == pMenu->GetMenuState(ID_MAINDLG_MINIMIZE, MF_BYCOMMAND) ) { pMenu->CheckMenuItem(ID_MAINDLG_MINIMIZE, MF_BYCOMMAND | MF_CHECKED); SwitchToFlag = 1; //SwitchToFlag为1,则在执行“切换至”操作时,任务管理器最小化 } else { SwitchToFlag = 0; pMenu->CheckMenuItem(ID_MAINDLG_MINIMIZE, MF_BYCOMMAND | MF_UNCHECKED); } } }