有谁知道桌面时钟程序怎么写? 本人想自己做个小的时钟,请教一下大家! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // CZJJ_ColockCtrl::OnDraw - Drawing functionvoid CZJJ_ColockCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid){ // TODO: Replace the following code with your own drawing code. pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH))); CPen pen(PS_SOLID,6,RGB(0,122,122)); pdc->SelectObject(&pen); pdc->Rectangle(rcBounds); //显示Colock中的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 - rcBounds.right/6; nLength_H = rcBounds.right/2 - rcBounds.right/5; } else { nLength_S = rcBounds.bottom/2 - rcBounds.bottom/7; nLength_M = rcBounds.bottom/2 - rcBounds.bottom/6; nLength_H = rcBounds.bottom/2 - rcBounds.bottom/5; } CPoint ptOrigin,ptEndS,ptEndM,ptEndH; //Origin Point ptOrigin.x = rcBounds.right/2; ptOrigin.y = rcBounds.bottom/2; CPen pen4(PS_SOLID,4,RGB(255,200,40)); pdc->SelectObject(&pen4); pdc->Rectangle(rcBounds.right/2-1,rcBounds.bottom/2+1,rcBounds.right/2+1,rcBounds.bottom/2-1); //Second ptEndS.x = (long)(nLength_S*cos(((nTime_s-15)*360/60)*PI/180) + ptOrigin.x); ptEndS.y = (long)(nLength_S*sin(((nTime_s-15)*360/60)*PI/180) + ptOrigin.y); //Minute ptEndM.x = (long)(nLength_M*cos(((nTime_m-15)*360/60)*PI/180) + ptOrigin.x); ptEndM.y = (long)(nLength_M*sin(((nTime_m-15)*360/60)*PI/180) + ptOrigin.y); //Hour if(nTime_h>=12) { ptEndH.x = (long)(nLength_H*cos(( ((nTime_h-12)*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.x); ptEndH.y = (long)(nLength_H*sin(( ((nTime_h-12)*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.y); } else { ptEndH.x = (long)(nLength_H*cos(( (nTime_h*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.x); ptEndH.y = (long)(nLength_H*sin(( (nTime_h*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.y); } //Draw CPen pen1(PS_SOLID,4,RGB(0,0,255)); pdc->SelectObject(&pen1); pdc->MoveTo(ptOrigin); pdc->LineTo(ptEndH); CPen pen2(PS_SOLID,2,RGB(255,0,255)); pdc->SelectObject(&pen2); pdc->MoveTo(ptOrigin); pdc->LineTo(ptEndM); CPen pen3(PS_SOLID,1,RGB(255,0,0)); pdc->SelectObject(&pen3); pdc->MoveTo(ptOrigin); pdc->LineTo(ptEndS);}//有点乱,以前写的,不知道能否有帮助 另起进程的问题 问一个MFC的按钮问题 命令消息与通知消息,如何界定呀?都是产生 WM_COMMAND 消息呀? 面向消息的协议是什么? HTTP数据包:如何识别哪个数据包是图片数据包? 如何将VC中的resource文件和XML相互转换。 怎么把一个位图变量给另外一个位图变量? 菜鸟系列问题之(二) MDI窗口的拆分问题 vs.net编译出错,请教高手? 恳请C++高手指教!!!!! 本人愿用自已开发的一套价值8百多的组件交换!!!! ADO如何获取记录在数据库中的位置
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code. pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH))); CPen pen(PS_SOLID,6,RGB(0,122,122));
pdc->SelectObject(&pen);
pdc->Rectangle(rcBounds); //显示Colock中的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 - rcBounds.right/6;
nLength_H = rcBounds.right/2 - rcBounds.right/5;
}
else
{
nLength_S = rcBounds.bottom/2 - rcBounds.bottom/7;
nLength_M = rcBounds.bottom/2 - rcBounds.bottom/6;
nLength_H = rcBounds.bottom/2 - rcBounds.bottom/5;
} CPoint ptOrigin,ptEndS,ptEndM,ptEndH;
//Origin Point
ptOrigin.x = rcBounds.right/2;
ptOrigin.y = rcBounds.bottom/2; CPen pen4(PS_SOLID,4,RGB(255,200,40));
pdc->SelectObject(&pen4);
pdc->Rectangle(rcBounds.right/2-1,rcBounds.bottom/2+1,rcBounds.right/2+1,rcBounds.bottom/2-1); //Second
ptEndS.x = (long)(nLength_S*cos(((nTime_s-15)*360/60)*PI/180) + ptOrigin.x);
ptEndS.y = (long)(nLength_S*sin(((nTime_s-15)*360/60)*PI/180) + ptOrigin.y);
//Minute
ptEndM.x = (long)(nLength_M*cos(((nTime_m-15)*360/60)*PI/180) + ptOrigin.x);
ptEndM.y = (long)(nLength_M*sin(((nTime_m-15)*360/60)*PI/180) + ptOrigin.y);
//Hour
if(nTime_h>=12)
{
ptEndH.x = (long)(nLength_H*cos(( ((nTime_h-12)*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.x);
ptEndH.y = (long)(nLength_H*sin(( ((nTime_h-12)*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.y);
}
else
{
ptEndH.x = (long)(nLength_H*cos(( (nTime_h*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.x);
ptEndH.y = (long)(nLength_H*sin(( (nTime_h*5-15+ nTime_m/15 )*360/60)*PI/180) + ptOrigin.y);
}
//Draw
CPen pen1(PS_SOLID,4,RGB(0,0,255));
pdc->SelectObject(&pen1);
pdc->MoveTo(ptOrigin);
pdc->LineTo(ptEndH); CPen pen2(PS_SOLID,2,RGB(255,0,255));
pdc->SelectObject(&pen2);
pdc->MoveTo(ptOrigin);
pdc->LineTo(ptEndM); CPen pen3(PS_SOLID,1,RGB(255,0,0));
pdc->SelectObject(&pen3);
pdc->MoveTo(ptOrigin);
pdc->LineTo(ptEndS);}
//有点乱,以前写的,不知道能否有帮助