65.9K
CodeProject is changing. Read more.
Home

Disable System Close Button on a Console Application

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.81/5 (23 votes)

Dec 7, 2003

CPOL
viewsIcon

105206

downloadIcon

3442

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.