要做的东东是这样的:写一个对话框,显示一个数字和一个button,当用户press down the button,数字每100毫秒增1,当用户释放button,每100毫秒减1 直到0;兄弟我知道大概怎么写,用向导生成了一个对话框,丢两个控件到上面,下面是我派生出的button类,增1减1这样的操作,兄弟我会的,只有一个问题想不太明白,算出的值假定存放在名为m_counter的变量中(这个变量是CMyButton的成员变量),我要怎样才能让它显示到对话框的编辑框中,调用UpdateData(FALSE),这个我知道.但是没法把编辑框和CMyButton的成员变量m_counter关联起来。DDX怎么弄?还请高人指点一二,急了。
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
    SetCapture();
    ....
    CButton::OnLButtonDown(nFlags, point);
}void CMyButton::OnLButtonUp(UINT nFlags, CPoint point)
{
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    ReleaseCapture();
    ....
    CButton::OnLButtonUp(nFlags, point);
}

解决方案 »

  1.   

    DDX_Control(pDX, IDC_EDIT1, m_counter);
      

  2.   

    问题是搞定了,可是又出了个意外在下面的事件处理中,为何占击左键后,只能显示20
    void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
    {
        SetCapture();
        CButton::OnLButtonDown(nFlags, point);
        static_cast<Ctest2Dlg *>(AfxGetApp()->m_pMainWnd)->m_counter = 10;
        static_cast<Ctest2Dlg *>(AfxGetApp()->m_pMainWnd)->UpdateData(FALSE);    Sleep(2000);
        static_cast<Ctest2Dlg *>(AfxGetApp()->m_pMainWnd)->m_counter = 20;
        static_cast<Ctest2Dlg *>(AfxGetApp()->m_pMainWnd)->UpdateData(FALSE);
    }