Solved

Enable Menu Item

Posted on 2000-04-21
3
1,020 Views
Last Modified: 2013-11-20
I need to disable the Maximize button on the CMainFrame, but why does my code works only for the the Close button and NOT for the Maximize button?

CMenu *pMenu = AfxGetMainWnd()->GetSystemMenu(FALSE) ;

// doesn't works!!
if (pMenu)  pMenu->EnableMenuItem(SC_MAXIMIZE, MF_BYCOMMAND|MF_DISABLED ) ;

// works!!
if (pMenu)  pMenu->EnableMenuItem(SC_CLOSE, MF_BYCOMMAND|MF_DISABLED ) ;
0
Comment
Question by:leowlf
3 Comments
 
LVL 8

Expert Comment

by:VinExpert
ID: 2737565
Hi,

To disable the maximize button, open ur mainframe.cpp and go to PreCreateWindow() function and at the start add the following line of code

      cs.style &= ~WS_MAXIMIZEBOX;

That should work. similarly for minimize button also.

Hope this helps.

VinExpert
0
 

Author Comment

by:leowlf
ID: 2737984
Sorry VinExpert,

I need to enable and disable the 'maximize' button during runtime under certain conditions.
0
 
LVL 30

Accepted Solution

by:
SteveGTR earned 50 total points
ID: 2738686
This appears to work, why the other doesn't work I do know:

CString str;

pMenu->GetMenuString(SC_MAXIMIZE, str, MF_BYCOMMAND);
pMenu->ModifyMenu(SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED, 0, str);

Good Luck,
Steve
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
Named range not carried over 10 65
iSeries DB2 Query 2 97
twoTwo  challenge 35 108
Use of condition with 'serial' in ansible 2 71
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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

820 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