这钟表界面我只做了个大概,用MFC建了个单文档程序,在CMainFram类的PreCreateWindow里加了两句cs.cx=200; cs.cy=290; 然后在View类的OnDraw函数里面整了一堆代码:
const CRect rcBounds(10,10,180,180);
const CRect rcInvalid(10,10,180,180);
pDC->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
CPen pen(PS_SOLID,6,RGB(0,122,122));
pDC->SelectObject(&pen);
pDC->Rectangle(rcBounds);
// 显示Clock里的3、6、9、12这几个数字
pDC->TextOut(rcBounds.right/2-8,rcBounds.top+rcBounds.bottom/12,12);
pDC->TextOut(rcBounds.right/2-4,rcBounds.bottom-rcBounds.bottom/12-17,6);
pDC->TextOut(rcBounds.left+rcBounds.right/12,rcBounds.bottom/2-4,9);
pDC->TextOut(rcBounds.right-rcBounds.right/12-8,rcBounds.bottom/2-4,3);
然后搞了个当前时间CTime time = CTime::GetCurrentTime();
int nTime_s = time.GetSecond();
int nTime_m = time.GetMinute();
int nTime_h = time.GetHour();
接着定义了几根指针长度int nLength_S,nLength_M,nLength_H;
if(rcBounds.right < rcBounds.bottom)
{
nLength_S = rcBounds.right/2 - rcBounds.right/7;
nLength_M = rcBounds.right/2 - r
const CRect rcBounds(10,10,180,180);
const CRect rcInvalid(10,10,180,180);
pDC->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
CPen pen(PS_SOLID,6,RGB(0,122,122));
pDC->SelectObject(&pen);
pDC->Rectangle(rcBounds);
// 显示Clock里的3、6、9、12这几个数字
pDC->TextOut(rcBounds.right/2-8,rcBounds.top+rcBounds.bottom/12,12);
pDC->TextOut(rcBounds.right/2-4,rcBounds.bottom-rcBounds.bottom/12-17,6);
pDC->TextOut(rcBounds.left+rcBounds.right/12,rcBounds.bottom/2-4,9);
pDC->TextOut(rcBounds.right-rcBounds.right/12-8,rcBounds.bottom/2-4,3);
然后搞了个当前时间CTime time = CTime::GetCurrentTime();
int nTime_s = time.GetSecond();
int nTime_m = time.GetMinute();
int nTime_h = time.GetHour();
接着定义了几根指针长度int nLength_S,nLength_M,nLength_H;
if(rcBounds.right < rcBounds.bottom)
{
nLength_S = rcBounds.right/2 - rcBounds.right/7;
nLength_M = rcBounds.right/2 - r