6、r(int k=0;k<30;k++){
pDC->MoveTo(a[j][0],a[j][1]);
pDC->LineTo(a[k][0],a[k][1]);
}
}
void CAaaaaView::OnLButtonDown(UINT nFlags, CPoint point) //缩放下左击放大,平移下平移
{
// TODO: Add your message handler code here and/or call default
if(a)
{
Xw=Xw/2;
Yw=Yw/2;
CPoint p=point;
pCu
7、rrentDC->DPtoLP(&p);
x0=Xw/4+p.x;
y0=Yw/4+p.y;
}
else{
CPoint b=point;
pCurrentDC->DPtoLP(&b);
x0=x0-b.x;
y0=y0-b.y;
}
Invalidate();
CView::OnLButtonDown(nFlags, point);
}
int CAaaaaView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct
8、) == -1)
return -1;
// TODO: Add your specialized creation code here
pCurrentDC= new CClientDC(this);
return 0;
}
void CAaaaaView::OnRButtonDown(UINT nFlags, CPoint point) //缩放下的右击缩小
{
// TODO: Add your message handler code here and/or call default
if(a)
{
Xw=Xw*2;
Yw=Yw
9、2;
CPoint p=point;
pCurrentDC->DPtoLP(&p);
x0=p.x+Xw/4;
y0=p.y+Yw/4;
Invalidate();}
CView::OnRButtonDown(nFlags, point);
}
void CAaaaaView::On1() //缩放菜单
{
// TODO: Add your command handler code here
a=true;
}
void CAaaaaView::On2() //平移菜单
{
// TODO: Add your command handler code here
a=false;
}
实验体会:
本次实验让我懂得如何去平移一个物体,也让我懂得如何缩放物体。