Click here to Skip to main content
Licence CPOL
First Posted 6 Dec 2003
Views 67,288
Downloads 1,885
Bookmarked 17 times

Disable System Close Button on a Console Application

By John L. DeVito | 6 Dec 2003
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
9 votes, 40.9%
1
2 votes, 9.1%
2
1 vote, 4.5%
3
6 votes, 27.3%
4
4 votes, 18.2%
5
2.64/5 - 22 votes
μ 2.57, σa 2.92 [?]

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)

About the Author

John L. DeVito

Architect
None
United States United States

Member

Follow on Twitter Follow on Twitter
Teaching myself Microsoft technologies after initially learning from open source mainly linux/c.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generaleasiest way to disable the close button in console window Pinmemberrix18:07 2 Oct '10  
Question#include "DisableCloseBtn.h" Pinmember000dreamsound0006:37 18 Jul '07  
Hi when I download the source code I can't obtain the "DisableCloseBtn.h" file. Please help
AnswerRe: #include "DisableCloseBtn.h" PinmemberJohn L. DeVito16:49 18 Jul '07  
GeneralEasier way Pinmembersgtawol6:01 7 Aug '06  
Questionhow to add item to windows explorer popUp menue Pinmemberwow_tato7:29 24 Dec '03  
GeneralThis one is really easy PinsussJesterka3:55 9 Dec '03  
GeneralRe: This one is really easy Pinmemberkha0s9:22 9 Dec '03  
QuestionWhy? Pinmemberdog_spawn13:42 7 Dec '03  
AnswerRe: Why? Pinsusshrabe23:22 7 Dec '03  
GeneralRe: Why? Pinmemberdog_spawn5:33 8 Dec '03  
GeneralRe: Why? PinmemberThe___Dude10:02 6 Sep '07  
AnswerRe: Why? Pinmemberkha0s6:20 8 Dec '03  
GeneralRe: Why? PinmemberAnthony_Yio17:03 10 Dec '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.

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