我用的是对话框模板,程序已完成了,并且运行正常,
想要改变对话框的颜色,后来添加了WM_CTLCOLOR函数,
结果我添加WM_CTLCOLOR函数后,还没在函数里写任何代码,
编译时就有37个错误!
全部是说我定义过的变量和函数未定义!
这个是什么问题?

解决方案 »

  1.   

    HBRUSH CButtonDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }没错啊!
      

  2.   

    hoho,不好意思
    我刚学VC,什么都不懂
      

  3.   

    HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }
    F:\我的文档\VC文档\取球大战2.0版\取球大战Dlg.cpp(406) : error C2065: 'GAME' : undeclared identifier
    F:\我的文档\VC文档\取球大战2.0版\取球大战Dlg.cpp(442) : error C2039: 'FIBFUNCTION' : is not a member of 'CMyDlg'
            f:\我的文档\vc文档\取球大战2.0版\取球大战dlg.h(14) : see declaration of 'CMyDlg'
    ……………………
    F:\我的文档\VC文档\取球大战2.0版\取球大战Dlg.cpp(633) : error C2440: '=' : cannot convert from 'char [7]' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    F:\我的文档\VC文档\取球比赛2.0版\取球比赛Dlg.cpp(637) : error C2660: 'MessageBoxA' : function does not take 1 parameters
    F:\我的文档\VC文档\取球比赛2.0版\取球比赛Dlg.cpp(642) : error C2660: 'MessageBoxA' : function does not take 1 parameters
    Error executing cl.exe.取球比赛.exe - 37 error(s), 0 warning(s)
      

  4.   

    Tell us something about how did you add that OnCtlColor() Function... I think the prolbem must come from here...
      

  5.   

    Ctrl+W->MFC ClassWizard->Message Maps
    ->Class Name:CMyDlg,  Object IDS:CMyDlg,  Messages:WM_CTLCOLOR
    ->ADD FUNCTION->确定->编译->出错!
      

  6.   

    删除过程:
    Ctrl+W->MFC ClassWizard->Message Maps
    ->Class Name:CMyDlg,  Object IDS:CMyDlg,  Messages:WM_CTLCOLOR
    ->DELETE FUNCTION->确定
    ->CMyDly下删除HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd,UINT nCtlColor)函数体
    ->编译->还是出错!
      

  7.   

    那怎么知道是加了onctlcolor后才出现的问题,晕。
      

  8.   

    --------------------Configuration: 取球比赛 - Win32 Debug--------------------
    Compiling...
    取球比赛Dlg.cpp
    Linking...取球比赛.exe - 0 error(s), 0 warning(s)这是没加之前的