Click to See Complete Forum and Search --> : MFC Dialog: How to enable/disable the 'Close' button of your dialog at run-time?


RNEELY
February 16th, 2004, 12:32 PM
Q: How to enable/disable the 'Close' button of your dialog at run-time?

A:


BOOL bEnable = TRUE; // To enable
BOOL bEnable = FALSE; // To disable

UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);

CMenu* pSM = GetSystemMenu(FALSE);
if(pSM)
{
pSM->EnableMenuItem(SC_CLOSE, menuf);
}

<br><br>