Here is the way I do it....

In OnInitDialog function:

CMenu* pSysMenu1 = GetSystemMenu(FALSE);

if (pSysMenu1 != NULL)
{
//disable the X
pSysMenu1->EnableMenuItem (SC_CLOSE,...