?
Solved

Disabling the "X" button

Posted on 1998-06-09
5
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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