[求助]你们帮我解释以下的问题?????
[size=3][size=4][size=4][color=#dc143c][color=#dc143c]// clockview.cpp : implementation of the cclockview class // #include "stdafx.h" #include "clock.h" #include "clockdoc.h" #include "clockview.h" #include "math.h" #ifdef _debug #define new debug_new #undef this_file static char this_file[] = __file__; #endif ///////////////////////////////////////////////////////////////////////////// // cclockview implement_dyncreate(cclockview, cview) begin_message_map(cclockview, cview) //{{afx_msg_map(cclockview) on_wm_create() on_wm_timer() //}}afx_msg_map // standard printing commands on_command(id_file_print, cview::onfileprint) on_command(id_file_print_direct, cview::onfileprint) on_command(id_file_print_preview, cview::onfileprintpreview) end_message_map() ///////////////////////////////////////////////////////////////////////////// // cclockview construction/destruction cclockview::cclockview() { // todo: add construction code here } cclockview::~cclockview() { } bool cclockview::precreatewindow(createstruct& cs) { // todo: modify the window class or styles here by modifying // the createstruct cs return cview::precreatewindow(cs); } ///////////////////////////////////////////////////////////////////////////// // cclockview drawing void cclockview::ondraw(cdc* pdc) { cclockdoc* pdoc = getdocument(); assert_valid(pdoc); // todo: add draw code for native data here //获取客户区 rect rect; getclientrect(&rect); //计算椭圆中心位置 int centerx = rect.right/2; int centery = rect.bottom/2; //取当前时间 ctime time = ctime::getcurrenttime(); cstring str; int i=1,x,y; csize size; //创建一支黄色的笔,用来画椭圆 cpen pen(ps_solid,5,rgb(255,255,0)); //设置当前画笔,并记下以前的画笔 cpen *oldpen = pdc->selectobject(&pen); //绘制种面椭圆 pdc->ellipse(5,5,rect.right-5,rect.bottom-5); double radians; //设置字体颜色为红色 pdc->settextcolor(rgb(255,0,0)); for(i=12;i>0;i--) { //格式化种点值 str.format("%d",i); size = pdc->gettextextent(str,str.getlength()); radians = (double)i*6.28/12.0; //设置钟点值 x = centerx-(size.cx/2)+(int)((double)(centerx-20)*sin(radians)); y = centery-(size.cy/2)-(int)((double)(centery-20)*cos(radians)); //绘制钟点 pdc->textout(x,y,str); } //计算时钟指针的夹角 radians = (double)time.gethour()+(double)time.getminute()/60.0+(double)time.getsecond()/3600.0; radians *=6.28/12.0; //创建时钟指针画笔 cpen hourpen(ps_solid,5,rgb(0,255,0)); pdc->selectobject(&hourpen); //绘制时钟指针 pdc->moveto(centerx,centery); pdc->lineto(centerx+(int)((double)(centerx/3)*sin(radians)),centery-(int)((double)(centery/3)*cos(radians))); //计算分钟指针夹角 radians = (double)time.getminute()+(double)time.getsecond()/60.0; radians *= 6.28/60; //创建分钟指针画笔 cpen minutepen(ps_solid,3,rgb(0,0,255)); pdc->selectobject(&minutepen); //绘制分钟指针 pdc->moveto(centerx,centery); pdc->lineto(centerx+(int)((double)(centerx*2)/3*sin(radians)),centery-(int)((double)(centery*2)/3*cos(radians))); //计算秒钟指针的夹角 radians = (double)time.getsecond(); radians *= 6.28/60.0; //创建秒钟指针画笔 cpen secondpen(ps_solid,1,rgb(0,255,255)); pdc->selectobject(&secondpen); //绘制秒钟指针 pdc->moveto(centerx,centery); pdc->lineto(centerx+(int)((double)(centerx*4)/5*sin(radians)),centery-(int)((double)(centery*4)/5*cos(radians))); //恢复原先的画笔 pdc->selectobject(&oldpen); } ///////////////////////////////////////////////////////////////////////////// // cclockview printing bool cclockview::onprepareprinting(cprintinfo* pinfo) { // default preparation return doprepareprinting(pinfo); } void cclockview::onbeginprinting(cdc* /*pdc*/, cprintinfo* /*pinfo*/) { // todo: add extra initialization before printing } void cclockview::onendprinting(cdc* /*pdc*/, cprintinfo* /*pinfo*/) { // todo: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // cclockview diagnostics #ifdef _debug void cclockview::assertvalid() const { cview::assertvalid(); } void cclockview::dump(cdumpcontext& dc) const { cview::dump(dc); } cclockdoc* cclockview::getdocument() // non-debug version is inline { assert(m_pdocument->iskindof(runtime_class(cclockdoc))); return (cclockdoc*)m_pdocument; } #endif //_debug ///////////////////////////////////////////////////////////////////////////// // cclockview message handlers int cclockview::oncreate(lpcreatestruct lpcreatestruct) { if (cview::oncreate(lpcreatestruct) == -1) return -1; // todo: add your specialized creation code here //设置计时器,1秒发送一次消息 settimer(1,1000,null); return 0; } void cclockview::ontimer(uint nidevent) { // todo: add your message handler code here and/or call default invalidaterect(null,true); updatewindow(); cview::ontimer(nidevent); } @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@1.y = centery-(size.cy/2)-(int)((double)(centery-20)*cos(radians));中的(size.cy/2)是什么意思?(centery-20)又是什么意思? 2.pdc->lineto(centerx+(int)((double)(centerx/3)*sin(radians)),centery-(int)((double)(centery/3)*cos(radians)));中的(centery/3)是什么意思? 3.pdc->lineto(centerx+(int)((double)(centerx*2)/3*sin(radians)),centery-(int)((double)(centery*2)/3*cos(radians)));中的(centery*2)/3是什么意思? 4.pdc->lineto(centerx+(int)((double)(centerx*4)/5*sin(radians)),centery-(int)((double)(centery*4)/5*cos(radians)));中的(centery*4)/5是什么意思? 5.//计算秒钟指针的夹角 radians = (double)time.getsecond(); radians *= 6.28/60.0; 这句radians *= 6.28/60.0是什么意思?为什么不是除以3600.0?而那个*又是代表什么意思? 6.invalidaterect(null,true);是什么意思? [/color]你们会多少,就回答多少;尽量帮我解决这些问答。
|