Click here to Skip to main content
11,431,829 members (65,547 online)
Click here to Skip to main content

Disable System Close Button on a Console Application

, 6 Dec 2003 CPOL
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

Introduction

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.

License

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

Share

About the Author

John L. DeVito
Student
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 Pin
rix2-Oct-10 18:07
memberrix2-Oct-10 18:07 
GeneralRe: easiest way to disable the close button in console window Pin
knestel5-Dec-13 3:35
memberknestel5-Dec-13 3:35 
Question#include "DisableCloseBtn.h" Pin
000dreamsound00018-Jul-07 6:37
member000dreamsound00018-Jul-07 6:37 
AnswerRe: #include "DisableCloseBtn.h" Pin
John L. DeVito18-Jul-07 16:49
memberJohn L. DeVito18-Jul-07 16:49 
GeneralEasier way Pin
sgtawol7-Aug-06 6:01
membersgtawol7-Aug-06 6:01 
Questionhow to add item to windows explorer popUp menue Pin
wow_tato24-Dec-03 7:29
memberwow_tato24-Dec-03 7:29 
GeneralThis one is really easy Pin
Jesterka9-Dec-03 3:55
sussJesterka9-Dec-03 3:55 
GeneralRe: This one is really easy Pin
kha0s9-Dec-03 9:22
memberkha0s9-Dec-03 9:22 
QuestionWhy? Pin
dog_spawn7-Dec-03 13:42
memberdog_spawn7-Dec-03 13:42 
AnswerRe: Why? Pin
hrabe7-Dec-03 23:22
susshrabe7-Dec-03 23:22 
GeneralRe: Why? Pin
dog_spawn8-Dec-03 5:33
memberdog_spawn8-Dec-03 5:33 
GeneralRe: Why? Pin
The___Dude6-Sep-07 10:02
memberThe___Dude6-Sep-07 10:02 
AnswerRe: Why? Pin
kha0s8-Dec-03 6:20
memberkha0s8-Dec-03 6:20 
GeneralRe: Why? Pin
Anthony_Yio10-Dec-03 17:03
memberAnthony_Yio10-Dec-03 17: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 | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 7 Dec 2003
Article Copyright 2003 by John L. DeVito
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid