在对话框中有一个编辑框,还有一个Spin控件与其相关联,当编辑框的内容随着Spin改变时,有一个静态框的内容随着编辑框中的内容改变而改变,怎么实现? 

解决方案 »

  1.   

    两者关联同一个CString的变量就行了,呵呵
      

  2.   

    可以在编辑框的EN_CHANGE消息响应事件中修改静态框的内容
      

  3.   

    我查MSDN也查到了,请看看下面的用法是否正确
    void CMemoryManagementDlg::OnChangeEdtPagemem() 
    {
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO: Add your control notification handler code here
    m_strStaMem.Format("%d", m_nEdtPageMem);    //静态框是CString类型的,编辑框是int型的,静态框里的内容不能随着编辑框的改变而改变
    }
      

  4.   

    void CMemoryManagementDlg::OnChangeEdtPagemem() 

    // TODO: If this is a RICHEDIT control, the control will not 
    // send this notification unless you override the CDialog::OnInitDialog() 
    // function and call CRichEditCtrl().SetEventMask() 
    // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here 
    UpdateData(true);
    m_strStaMem.Format("%d", m_nEdtPageMem);    //静态框是CString类型的,编辑框是int型的,静态框里的内容不能随着编辑框的改变而改变 
    UpdateData(fasle);
    }
      

  5.   

    我也试过了上面的方法了,加上UpdateData时编译没有错,但是运行时有错,不能运行。出现Debug Assertion failed的错误。