设置不同的返回值来关闭对话框.txt

来自「图像处理学习的一些心得」· 文本 代码 · 共 26 行

TXT
26
字号
// MyWnd.cpp
#include "MyDialog.h"

void CMyWnd::ShowDialog()
{
  CMyDialog myDlg;
  int nRet = myDlg.DoModal();

  if ( nRet == IDOK || nRet == 5  )
    AfxMessageBox("Dialog closed successfully");
}

// MyDialog.cpp
void CMyDialog::OnSomeAction()
{
  // Do something.

  int nRet = 5; // Any value will do.
  EndDialog(nRet); // This value is returned by DoModal.

  // Do something.

  return; // Dialog closed and DoModal returns only here.
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?