Here is an example for you that will enable/disable the close button in runtime:
BOOL bEnable = FALSE;
UINT nMenuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if(pSysMenu)
{
pSysMenu->EnableMenuItem(SC_CLOSE, nMenuf);
}
You will need to place this code in appropriate place (i.e. in
OnInitDialog
) of your dialog class. :)