- 注册时间
- 2011-3-6
- 最后登录
- 1970-1-1
该用户从未签到
|
代码:
//POINT的数组可以这么用
POINT pt[]={
0, 450,
225,390,
390,225,
450,0,
390,-225,
225,-390,
0,-450,
-225,-390,
-390,-225,
-450,0,
-390,225,
-225,390
};
SetIsotropic函数:设置坐标系
//改变坐标系就用这四个函数void SetIsotropic(HDC hdc, int cx, int cy){::SetMapMode(hdc, MM_ISOTROPIC); //设置坐标映射方式::SetWindowExtEx(hdc, 1000, 1000, NULL); //设置坐标系的逻辑单位::SetViewportExtEx(hdc, cx, -cy, NULL); //设置坐标系方向和坐标系包含的范围,即定义域和值域::SetViewportOrgEx(hdc, cx/2, cy/2, NULL);
//设置坐标系原点坐标}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
//画钟表盘
int cxClient, cyClient;
RECT rect;
::GetClientRect(hWnd, &rect);
cxClient = rect.right - rect.left;
cyClient = rect.bottom - rect.top;
SetIsotropic(hdc, cxClient, cyClient);
#define SQUARESIZE 10
::SelectObject(hdc, ::GetStockObject(BLACK_BRUSH));
for(int i=0;i<12;i++)
{
::Ellipse(hdc, pt[i].x-SQUARESIZE,pt[i].y+SQUARESIZE,pt[i].x+SQUARESIZE, pt[i].y-SQUARESIZE);
}
EndPaint(hWnd, &ps);
break; |
|