Solved

Disabling the "X" button

Posted on 1998-06-09
5
237 Views
Last Modified: 2013-11-20
I would like to know how to disable the "X" button in the upper right corner of a Windows application.
I want the user to be able to exit only using the pull-down menu option File->Exit.

Thanks.
0
Comment
Question by:horn
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
ID: 1317816
That you need to do this suggests there's something wrong with the design of your app--why don't you execut the same code in response to WM_CLOSE and WM_COMMAND(ID_FILE_EXIT)?

Anyway, you can just get the system menu and disable the SC_CLOSE command to make the close command and the non-client button both disabled:

   CMenu* pMenu = GetSystemMenu(FALSE);
   pMenu->EnableMenuItem(SC_CLOSE, MF_DISABLED | MF_GRAYED);

B ekiM

0
 
LVL 2

Expert Comment

by:VEngineer
ID: 1317817
If you just simply want to get rid of the 'X' button, you can go into the dialog box properties, styles, and then uncheck "system menu"
This will can the 'X' but it will also can the button in the upper left too.  So all you have is a title bar with the title text.  Menu will still work fine.

0
 
LVL 2

Expert Comment

by:VEngineer
ID: 1317818
I'm not sure which solution you are looking for, but if my solution works, please give me some points.. I am running low.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1317819
Horn asked about disabling the button, not getting rid of it entirely. If you need points, you should answer the question that was asked correctly (like I did), not answer a question you made up yourself.

B ekiM
0
 

Author Comment

by:horn
ID: 1317820
I am sorry but to be fair, the points have to go to the first one to answer correctly.
Thanks B ekiM.


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 86
sum13 challenge 24 134
Problem to open Excel file 15 223
Windows shortcut location resolution on double click open 4 53
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question