我的程序有部分代码如下:
现在我只能做出两个判断要么nResponse == IDOK要么nResponse == IDCANCEL,可是如果我的有一个button1在dlg上,我如何得到这个消息呢?nResponse应该==什么呢?本人是初学vc望各位大侠说的详细一点,谢谢!
CMyDialog dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}

解决方案 »

  1.   

    点button1是没有用的
    只有关闭对话框才有Response
      

  2.   

    它有自己的消息函数啊。如BUTTONDOWN BUTTONUP
      

  3.   

    nResponse(== IDOK,IDCANCEL) 是关闭窗口时的到的消息,
      

  4.   

    使用CDialog的成员函数EndDialog,其参数带入你想要返回值即可
      

  5.   

    Python正解,顺便鄙视一些误人子弟的星级人员。
      

  6.   

    搂主也许真的不知道
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    }
    是在对话框关闭后才执行的,对Button1的处理放在CMyDialog里边。
      

  7.   

    OnOK也是调用EndDialog的,在按钮的处理函数结束时调用EndDialog(x)就可以了