MFC Dialog: How to enable/disable the 'Close' button of your dialog at run-time?

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)
;
}

Note: Most of the material in this article is taken from codeguru.com


Recommended Reading :





Cheap Gas - Loans - Internet Marketing - Loans