MFC的SC_CLOSE中选择'NO'时如何return应用程序

How to return the application when choosing 'NO' in SC_CLOSE of MFC

我在 MFC 中使用关闭 x 按钮。我用代码来处理 even

void Main_MFCDlg::OnSysCommand(UINT nID, LPARAM lParam)
{

    if(nID == SC_CLOSE)
    {
      if(MessageBox(_T("Are you ready to exit?"), _T("Message"), MB_YESNO) == IDYES);
        {
            // Exit here- Done
        }
      else
        {
         //Return application
        }

    }

    else
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}

现在,我想点击选项'No',那么应用程序仍然会运行。如何编写代码来完成该任务?谢谢

Return如果不想退出,或者允许默认处理:

void OnSysCommand(UINT nID, LPARAM lParam)
{
    if (nID == SC_CLOSE)
    {
        if (MessageBox(_T("Are you ready to exit?"), _T("Message"), MB_YESNO) == IDNO)
        {
            return;
        }
    }

    CDialog::OnSysCommand(nID, lParam);
}