void CClockView::DrawClockFace(CDC *pDC)
{
        const CPoint point[12] = {
        CPoint (   0,  450),    // 12 o'clock
        CPoint ( 225,  390),    //  1 o'clock
        CPoint ( 390,  225),    //  2 o'clock
        CPoint ( 450,    0),    //  3 o'clock
        CPoint ( 390, -225),    //  4 o'clock
        CPoint ( 225, -390),    //  5 o'clock
        CPoint (   0, -450),    //  6 o'clock
        CPoint (-225, -390),    //  7 o'clock
        CPoint (-390, -225),    //  8 o'clock
        CPoint (-450,    0),    //  9 o'clock
        CPoint (-390,  225),    // 10 o'clock
        CPoint (-225,  390),    // 11 o'clock
    };
    pDC->SelectStockObject (NULL_BRUSH);    for (int i=0; i<12; i++)
        pDC->Rectangle (point[i].x - SQUARESIZE,
            point[i].y + SQUARESIZE, point[i].x + SQUARESIZE,
            point[i].y - SQUARESIZE);
}void CClockView::OnPaint() 
{
CRect rect;
GetClientRect(&rect);
CPaintDC dc(this); // device context for painting
dc.SetMapMode(MM_ISOTROPIC);
         /*
dc.SetWindowExt(1000,1000);
dc.SetViewportExt(rect.Width(),-rect.Height());
dc.SetViewportExt(rect.Width()/2,rect.Height()/2);
         */
DrawClockFace(&dc);
}
效果是整体左上移,只显示一点点图像,
而我原本的意思是想将Client的中间定为(0,0)坐标,

解决方案 »

  1.   

    问题弄请了,
    现请问我画秒针的时候,为什么前面的线无法去掉呢?就像有好多根秒针一样,代码如下:
    void CClockView::DrawSecondHand(CDC *pDC, int nLength, int nSecond, COLORREF clrColor)
    {
    CPoint point[2];
    double nRadians=(double)nSecond *PI/30;
    point[0].x=(int)nLength * sin(nRadians);
    point[0].y=(int)nLength * cos(nRadians);
    point[1].x=-point[0].x/8;
    point[1].y=-point[0].y/8; CPen pen;
    pen.CreatePen(PS_SOLID,1,clrColor);
    pDC->SelectObject(&pen);
    pDC->MoveTo(point[0]);
    pDC->LineTo(point[1]);
    pen.DeleteObject();
    }