[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Disabling the "X" button

Posted on 1998-06-09
5
Medium Priority
?
241 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

872 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