VC++ 帮我理解一下使图形变化的算法void CMfc1View::OnDraw(CDC* pDC){\x05CMfc1Doc* pDoc = GetDocument();\x05ASSERT_VALID(pDoc);\x05// TODO:add draw code for native data here\x05//清除当前图形\x05CBrush mybrush1;\x05mybrush1.CreateSol

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 07:54:38
VC++ 帮我理解一下使图形变化的算法void CMfc1View::OnDraw(CDC* pDC){\x05CMfc1Doc* pDoc = GetDocument();\x05ASSERT_VALID(pDoc);\x05// TODO:add draw code for native data here\x05//清除当前图形\x05CBrush mybrush1;\x05mybrush1.CreateSol
xVmOV+K' MaNV!2AӤɍ/`8@;D)oI_ hKTBΧ$qݾNʋssys=7!bAK?ӳ/jqZ-. qN$FW'z!}\ ?C Ijŵ8uNM ex K߻KAy{\~S _~n_޾27DS!YV%HF,D Ô =U?,o~s]#bSם$FBds-FDD"Sξ#O->57:8. ^A21@Vz̥XS-BWsocZ+[L/O]?73*ayERO82΃i5T7zOh 'FċXC,BEa.%*.7'Y* >V@/UP:NQFDZ~u,jC aCc/u9*sKN5 FCTmp7SY5;\ CtG#A6Ą3|9\*aQl-M[JJ`T=10bC!.+ֺp Ʊzka 2 `%Cqe\ϳumzY=I%0.El[mZ\~e=mj+GdeN_;2>z)O 됨Z*iO2 1%C `[Ua͘)BQ3d㘆#Nf?ˎ{( @ʜRAD^/x-7H=iqhB{ 1l*@-,yxڐb~\{k\l l䳐ם{

VC++ 帮我理解一下使图形变化的算法void CMfc1View::OnDraw(CDC* pDC){\x05CMfc1Doc* pDoc = GetDocument();\x05ASSERT_VALID(pDoc);\x05// TODO:add draw code for native data here\x05//清除当前图形\x05CBrush mybrush1;\x05mybrush1.CreateSol
VC++ 帮我理解一下使图形变化的算法
void CMfc1View::OnDraw(CDC* pDC)
{
\x05CMfc1Doc* pDoc = GetDocument();
\x05ASSERT_VALID(pDoc);
\x05// TODO:add draw code for native data here
\x05//清除当前图形
\x05CBrush mybrush1;
\x05mybrush1.CreateSolidBrush(RGB(255,255,255));
\x05CRect myrect1(0,0,1024,768);
\x05pDC->FillRect(myrect1,&mybrush1);
\x05//判断当前图形ituxing
/*\x05if(ituxing==1)
\x05//ituxing=1,画矩形
\x05\x05pDC->Rectangle(20,20,89,89);
\x05else if(ituxing==2)
\x05//ituxing=2,画圆
\x05\x05\x05pDC->Ellipse(20,20,89,89);
\x05else
\x05//否则,画三角形
\x05\x05{
\x05\x05\x05pDC->MoveTo(20,20);
\x05\x05\x05pDC->LineTo(89,45);
\x05\x05\x05pDC->LineTo(20,89);
\x05\x05\x05pDC->LineTo(20,20);
\x05\x05}*/
\x05pDC->Ellipse(30*ituxing,30*ituxing,30*ituxing+50,30*ituxing+50);
\x05// TODO:add draw code for native data here
}
void CMfc1View::OnTimer(UINT nIDEvent)
{
\x05// TODO:Add your message handler code here and/or call default
\x05//获取指针pdc
\x05if(nIDEvent == 1)
\x05{
\x05ituxing = (ituxing+1)%10;
\x05CDC *pDC=GetDC();
\x05//调用OnDraw(pDC)重画
\x05OnDraw(pDC);
\x05//使ituxing循环
ituxing=(ituxing+1)%3;
\x05}
\x05
\x05CView::OnTimer(nIDEvent);
}
int CMfc1View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
\x05if (CView::OnCreate(lpCreateStruct) == -1)
\x05\x05return -1;
\x05// TODO:Add your specialized creation code here
\x05//设置更新时间
\x05SetTimer(1,1000,NULL);
\x05return 0;
}
提问:怎么理解ituxing=(ituxing+1)%3;这行呢.ituxing 也不是个随机数啊?

VC++ 帮我理解一下使图形变化的算法void CMfc1View::OnDraw(CDC* pDC){\x05CMfc1Doc* pDoc = GetDocument();\x05ASSERT_VALID(pDoc);\x05// TODO:add draw code for native data here\x05//清除当前图形\x05CBrush mybrush1;\x05mybrush1.CreateSol
ituxing是给定的任意一个整数.可以是0~65535,也可能是个更小的范围,取决于ituxing这个变量的数据类型.
%叫做取余运算符,结果是整数除法中的余数.这种算法常被用来进行大数转小数的限定.
ituxing = (ituxing+1)%3
这句使得无论ituxing之前是个什么值,1,10000,453,都可以,经过上式的计算,都可以把ituxing变成0,1,2三个数,这样可以用于你下面语句的判断.可以使用switch case 语句.