Click here to Skip to main content
13,045,417 members (125,006 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 6 Dec 2003

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
United States United States
Teaching myself Microsoft technologies after initially learning from open source mainly linux/c.

You may also be interested in...


Comments and Discussions

Generaleasiest way to disable the close button in console window Pin
rix2-Oct-10 17:07
memberrix2-Oct-10 17:07 
GeneralRe: easiest way to disable the close button in console window Pin
knestel5-Dec-13 2:35
memberknestel5-Dec-13 2:35 
Question#include "DisableCloseBtn.h" Pin
000dreamsound00018-Jul-07 5:37
member000dreamsound00018-Jul-07 5:37 
AnswerRe: #include "DisableCloseBtn.h" Pin
John L. DeVito18-Jul-07 15:49
memberJohn L. DeVito18-Jul-07 15:49 
GeneralEasier way Pin
sgtawol7-Aug-06 5:01
membersgtawol7-Aug-06 5:01 
Questionhow to add item to windows explorer popUp menue Pin
wow_tato24-Dec-03 6:29
memberwow_tato24-Dec-03 6:29 
GeneralThis one is really easy Pin
Jesterka9-Dec-03 2:55
sussJesterka9-Dec-03 2:55 
GeneralRe: This one is really easy Pin
kha0s9-Dec-03 8:22
memberkha0s9-Dec-03 8:22 
QuestionWhy? Pin
dog_spawn7-Dec-03 12:42
memberdog_spawn7-Dec-03 12:42 
AnswerRe: Why? Pin
hrabe7-Dec-03 22:22
susshrabe7-Dec-03 22:22 
GeneralRe: Why? Pin
dog_spawn8-Dec-03 4:33
memberdog_spawn8-Dec-03 4:33 
GeneralRe: Why? Pin
The___Dude6-Sep-07 9:02
memberThe___Dude6-Sep-07 9:02 
AnswerRe: Why? Pin
kha0s8-Dec-03 5:20
memberkha0s8-Dec-03 5:20 
GeneralRe: Why? Pin
Anthony_Yio10-Dec-03 16:03
memberAnthony_Yio10-Dec-03 16:03 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 7 Dec 2003
Article Copyright 2003 by John L. DeVito
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid