| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1313 人关注过本帖
标题:求教一个关于MFC的问题--改错
只看楼主 加入收藏
wei0000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:80
专家分:136
注 册:2010-3-12
结帖率:91.67%
收藏
已结贴  问题点数:20 回复次数:5 
求教一个关于MFC的问题--改错
#include<afxwin.h>
#include<afxext.h>

#define SeedRand() srand(UINT)::GetTickCount()

class CMyApp:public CWinApp{
    public:
        virtual BOOL InitInstance();
};

class CMainWnd:public CFrameWnd{
    protected:
        int  m_nCurScreen;
        CPoint rec_E;
        int R_rec;
        int L_rec;
        COLORREF GetRandomColor();
        UINT MapRand(UINT nMax);
        void Growing_Ellipse(CClientDC *pDC);
    public:
        CMainWnd();
        afx_msg void OnTimer(UINT IDtimer);
        DECLARE_MESSAGE_MAP();
};

//#include "CDCDEMO.H"
BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
    ON_WM_TIMER()
END_MESSAGE_MAP()

CMainWnd::CMainWnd(){
    rec_E.x=320;
    rec_E.y=480;
    R_rec=30;
    L_rec=10;
    SeedRand();   //这一句有俩个错误:D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(36) : error C2275: 'UINT' : illegal use of this type as an expression
        d:\vc98\include\windef.h(162) : see declaration of 'UINT'
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(36) : error C2143: syntax error : missing ';' before 'tag::id'
为什么会有这俩个错误?????????


}

COLORREF CMainWnd::GetRandomColor(){
    return RGB(MapRand(255),MapRand(255),MapRand(255));
}

UINT CMainWnd::MapRand(UINT nMax){
    int nRand=rand();
    float fMap=(float)nMax/RAND_MAX;
    float fRetVal=(float)nRand*fMap+0.5F;
    return (UINT)fRetVal;
}

void CMainWnd::OnTimer(UINT IDtimer){
    CClientDC dc(this);
    Growing_Ellipse(&dc);
}

void CMainWnd::Growing_Ellipse(CClientDC *pDC){
    CBrush ColorBrush(GetRandomColor());
    pDC->SelectObject(&ColorBrush);
    pDC->Ellipse(rec_E.x-R_rec,rec_E.y-R_rec*480/640,
        rec_E.x+R_rec,rec_E.y+R_rec*480/640);
    R_rec=R_rec+C_rec;  //D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(60) : error C2065: 'C_rec' : undeclared identifier

    if(rec_E-R_rec<=10||rec_E-R_rec>=300) C_rec-=C_rec; //  这一句也有俩个错误,为什么??? D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(61) : error C2679: binary '-' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(61) : error C2679: binary '-' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)

}

BOOL CMyApp::InitInstance(){
    CMainWnd *pFrame=new CMainWnd;
    pFrame->Create(0,"Graphics Demo",WS_POPUPWINDOW|WS_DLGFRAME,CRect(0,0,640,480));
    this->m_pMainWnd=pFrame;
    pFrame->ShowWindow(m_nCmdShow);
    pFrame->UpdateWindow();
    pFrame->SetTimer(0,50,NULL);
    return TRUE;
}

CMyApp MyApp;

编译后产生如下错误,望高手们帮助修改,并告诉我出错的原因,感激不尽!!!!!!!!??????????
///////////////////////////////////////////////////////////////////////////////////////
--------------------Configuration: MFC Ellipse - Win32 Debug--------------------
Compiling...
ellipse.cpp
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(36) : error C2275: 'UINT' : illegal use of this type as an expression
        d:\vc98\include\windef.h(162) : see declaration of 'UINT'
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(36) : error C2143: syntax error : missing ';' before 'tag::id'
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(60) : error C2065: 'C_rec' : undeclared identifier
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(61) : error C2679: binary '-' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
D:\visual c++\MSDev98\MyProjects\MFC Ellipse\ellipse.cpp(61) : error C2679: binary '-' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
Error executing cl.exe.

MFC Ellipse.exe - 5 error(s), 0 warning(s)

搜索更多相关主题的帖子: MFC 改错 
2010-03-26 09:55
秀痘魔导士
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:6
帖 子:250
专家分:1150
注 册:2009-12-23
收藏
得分:7 
C_rec没定义,当然报错。
2010-03-26 10:24
秀痘魔导士
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:6
帖 子:250
专家分:1150
注 册:2009-12-23
收藏
得分:0 
#define   SeedRand()   srand((UINT)::GetTickCount())   
2010-03-26 10:25
wei0000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:80
专家分:136
注 册:2010-3-12
收藏
得分:0 
能帮忙改改吗?
2010-03-26 12:41
秀痘魔导士
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:6
帖 子:250
专家分:1150
注 册:2009-12-23
收藏
得分:0 
以下是引用wei0000在2010-3-26 12:41:43的发言:

能帮忙改改吗?
都说到这份上了,自己写出一下吧。代码不想细看了,大学课程的题目。
2010-03-26 13:00
kldx1988
Rank: 1
等 级:新手上路
帖 子:6
专家分:7
注 册:2010-3-12
收藏
得分:7 
新手路过学习一下
2010-03-26 20:25
快速回复:求教一个关于MFC的问题--改错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015236 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved