IT_컴퓨터_코딩_개발

[c++] 콘솔 응용프로그램 종료 메뉴 없애기(Disable Close Menu and Button in Console application)

파워유저 2012. 12. 28. 15:27


// 콘솔 위치/크기 지정
HWND hwndConsole = ::GetConsoleWindow();
::MoveWindow(hwndConsole, 10, 10, 1024, 768, 1);


// Disable Close Button Only
//EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_GRAYED);  // => 처음에는 diable되지만 메뉴를 열어본 후에는 다시 enable된다.(Windows 7)
//DrawMenuBar(GetConsoleWindow());


// Remove Close Menu and Button
HMENU hmenu = ::GetSystemMenu(hwndConsole, FALSE);
::DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND);