Click here to Skip to main content
Click here to Skip to main content
Go to top

Disable System Close Button on a Console Application

, 6 Dec 2003
Rate this:
Please Sign up or sign in to vote.
This code is a simple way to disable the close button on a Windows Console Application. It can also be used to disable any of the system menu buttons


This program is a VERY simple one to demostrate how to disable the close button on a Windows Console App. When I was looking up how to do this, I failed to find anything to help me on the site save the forums.

In reality we simply need to call two separate functions GetSystemMenu() and DeleteMenu(). This same algorithm can be used to disable/enable ANY of the system menu buttons.

The entry point for YOUR code is in the else block after testing for MFC failure.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

John L. DeVito
Architect None
United States United States
Teaching myself Microsoft technologies after initially learning from open source mainly linux/c.
Follow on   Twitter

Comments and Discussions

Generaleasiest way to disable the close button in console window Pinmemberrix2-Oct-10 17:07 
GeneralRe: easiest way to disable the close button in console window Pinmemberknestel5-Dec-13 2:35 
Question#include "DisableCloseBtn.h" Pinmember000dreamsound00018-Jul-07 5:37 
AnswerRe: #include "DisableCloseBtn.h" PinmemberJohn L. DeVito18-Jul-07 15:49 
GeneralEasier way Pinmembersgtawol7-Aug-06 5:01 
Questionhow to add item to windows explorer popUp menue Pinmemberwow_tato24-Dec-03 6:29 
GeneralThis one is really easy PinsussJesterka9-Dec-03 2:55 
GeneralRe: This one is really easy Pinmemberkha0s9-Dec-03 8:22 
QuestionWhy? Pinmemberdog_spawn7-Dec-03 12:42 
AnswerRe: Why? Pinsusshrabe7-Dec-03 22:22 
GeneralRe: Why? Pinmemberdog_spawn8-Dec-03 4:33 
GeneralRe: Why? PinmemberThe___Dude6-Sep-07 9:02 
AnswerRe: Why? Pinmemberkha0s8-Dec-03 5:20 
GeneralRe: Why? PinmemberAnthony_Yio10-Dec-03 16:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Dec 2003
Article Copyright 2003 by John L. DeVito
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid