求用vc编 指针式时钟 源代码!
1.为该程序设计一个美观大方的图标2.可视化显示一个指针式时钟,显示当前的年,月,日和当前时间3.通过菜单和工具栏可以调整时间,设置显示风格、效果属性(比如指针,表盘的颜...
1.为该程序设计一个美观大方的图标
2.可视化显示一个指针式时钟,显示当前的年,月,日和当前时间
3.通过菜单和工具栏可以调整时间,设置显示风格、效果属性(比如指针,表盘的颜色、形状等)
4.通过菜单工具栏可以设置闹钟
5.当设置了闹钟,则在指针式时钟的面板上显示闹钟图标;时间到,通过图标闪烁方式提示;闹钟过后,取消闹钟图标
谢了 这个号所有的分数都在此了 高手帮帮忙 不然 我惨了呀
不方便发 也可以QQ联系 ! QQ:1037360040 展开
2.可视化显示一个指针式时钟,显示当前的年,月,日和当前时间
3.通过菜单和工具栏可以调整时间,设置显示风格、效果属性(比如指针,表盘的颜色、形状等)
4.通过菜单工具栏可以设置闹钟
5.当设置了闹钟,则在指针式时钟的面板上显示闹钟图标;时间到,通过图标闪烁方式提示;闹钟过后,取消闹钟图标
谢了 这个号所有的分数都在此了 高手帮帮忙 不然 我惨了呀
不方便发 也可以QQ联系 ! QQ:1037360040 展开
4个回答
展开全部
只实现了大体的时钟外观
用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);
//显示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);
在View类中添加OnInitialUpdate虚函数 设置一定时器
SetTimer(1,400,NULL);
在OnTimer函数中使窗口重绘
Invalidate();
用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);
//显示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);
在View类中添加OnInitialUpdate虚函数 设置一定时器
SetTimer(1,400,NULL);
在OnTimer函数中使窗口重绘
Invalidate();
展开全部
抱歉啦,这个问题我无能为力。来报个道。
Very sorry.
Very sorry.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该和简单,可惜我不想用VC了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个东西难倒不难的,麻烦,还要表盘的形状。。。。。
不知道vc做图都是用坐标画的啊,这得多少代码啊。
不然你用图做吧,做个背景图,添个指针上去,看坐标转圈
不知道vc做图都是用坐标画的啊,这得多少代码啊。
不然你用图做吧,做个背景图,添个指针上去,看坐标转圈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询