Solved

Enable Menu Item

Posted on 2000-04-21
3
992 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now