求教一个关于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)