mfc界面编程中!想给几个编辑框一组默认为0 的值,但是运行错误!
我关联的变量全部是CEdit类型 也就是控件类型的变量,再在OnInitDialog函数里面添加如下代码:
BOOL CAnalyzeDlg::OnInitDialog() 
{
// CDialog::OnInitDialog();
     CDialogEx::OnInitDialog();
m_Aturnerror.SetWindowText("0");
m_Atootherror.SetWindowText("0");
m_CircularRunout.SetWindowText("0");
m_Maxburr.SetWindowText("0");
m_MeasuredDeviation1.SetWindowText("0");
m_MeasuredDeviation2.SetWindowText("0");
// TODO: Add extra initialization here

return TRUE;  // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
为什么编译可以通过 一个error也没有  但是不能运行,运行的时候出现系统崩溃的问题!请问大侠如何解决????急急急~~~~

解决方案 »

  1.   

    try m_Aturnerror.SetWindowText(_T("0"));
    另外,你确定是这里的问题么
      

  2.   

    CDialogEx::OnInitDialog();
    确定你的Dialog是继承自CDialogEx?
      

  3.   

    按照你的方法。我试过。没问题的,所以不能执行不是这里的问题。。
    你在debug下。在Call stack看看执行的时候停留在哪里,哪里就可能出错。。
      

  4.   

    // CDialog::OnInitDialog();
      CDialogEx::OnInitDialog();
    还是换成CDialog::OnInitDialog();
      

  5.   

    还是看下CAnalyzeDlg的基类是哪个。CDialog? CDialogEx?
      

  6.   

    Debug下看哪个SetWindowText()导致ASSERT错误,控件变量是否关联正确?DoDataExchange里写的对不?
      

  7.   

    VC 6.0下测试通过:
    BOOL CAccuracyDlg::OnInitDialog()
    {
    CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
    CString strAboutMenu;
    strAboutMenu.LoadString(IDS_ABOUTBOX);
    if (!strAboutMenu.IsEmpty())
    {
    pSysMenu->AppendMenu(MF_SEPARATOR);
    pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
    } // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon
    m_ctrlEditSetting.SetWindowText("0");
    m_ctrlEditSettingLimit.SetWindowText("0");
    m_ctrlEditMeasure.SetWindowText("0");
    m_ctrlEditMeasureError.SetWindowText("0");
        
            return TRUE;  // return TRUE  unless you set the focus to a control
    }
    应该是控件变量关联问题。