Solved

Disabling the "X" button

Posted on 1998-06-09
5
236 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
mixString challenge 36 130
Pressing cancel button with C# UI Automation 3 80
maxBlock challenge 30 142
twoTwo  challenge 35 107
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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…

792 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