Link to home
Start Free TrialLog in
Avatar of leowlf
leowlf

asked on

Enable Menu Item

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 ) ;
Avatar of Vinayak Kumbar
Vinayak Kumbar

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
Avatar of leowlf

ASKER

Sorry VinExpert,

I need to enable and disable the 'maximize' button during runtime under certain conditions.
ASKER CERTIFIED SOLUTION
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial