请教一个问题:
对话框显示要用到DoModal()这个函数,他的返回值IDOK和IDCANCEL表示什么呢?
还有这个IDOK和IDCANCEL和具体到出现对话框后,上面的两个按钮OK和CANCEL
所对应的ID号IDOK和IDCANCEL是一样的吗?

解决方案 »

  1.   

    IDOK 表示用户单击确定按钮. IDCANCEL 表示用户单击了取消按钮, 或按ESC键, 或点击X关闭了对话框
      

  2.   

    The default OnOK member function will validate and update the dialog-box data and close the dialog box with result IDOK, and the default OnCancel member function will close the dialog box with result IDCANCEL without validating or updating the dialog-box data. You can override these message-handler functions to alter their behavior.
      

  3.   

    IDOK和IDCANCEL区别在于:当点击OK按纽时调用UpdateData()函数-》再调用卸载窗体函数;
                           当点击CANCEL按纽时直接调用卸载窗体函数;
    判断时可以不用写IDOK和IDCANCEL
    如:
    if(DoModal()==1){}    <====>if(DoModal()==IDOK){}
      

  4.   

    补充:返回值和按钮的ID号是一个意思,表示点击了哪个按钮就返回哪个按钮的ID号
      

  5.   

    void EndDialog(int nResult );可以关闭对话框,并且返回nResult,在默认情况下,你按OK按钮,CDialog::OnOK()函数被调用,而CDialog::OnOk()中调用EndDialog(IDOK),所有返回IDOK,IDCANCEL也是如此。所以你可以用不同的方法结束对话框,并且返回不同的值!