Solved

Enable Menu Item

Posted on 2000-04-21
3
1,001 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 123
only14 challenge 19 69
ASP.NET C# MessageBox.Show Showing a modal dialog box or form when the application ... 2 104
wordappend challenge 8 149
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 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

21 Experts available now in Live!

Get 1:1 Help Now