zoukankan      html  css  js  c++  java
  • EVC 下一个圆形时钟的代码

        CDC *pDC=this->GetDC();
        CRect rc(100,100,390,390); 
    //    GetClientRect( &rc );
        int xStart = (rc.right+rc.left)/2;
        int yStart = (rc.bottom+rc.top)/2;
        CTime time = CTime::GetCurrentTime();
        CString strDigits;
        int i,x,y;
        CSize size;    
        CPen Pen(PS_SOLID,5,RGB(0,0,0));
        CPen *pOldPen=pDC->SelectObject(&Pen);
        pDC->Ellipse(rc.left+5,rc.top+5,rc.right-5,rc.bottom-5);
        double Radians;
        pDC->SetTextColor(RGB(0,0,0));
        for(i=1; i<=12; i++){
            strDigits.Format(_T("%d"),i);
            size =pDC->GetTextExtent(strDigits,strDigits.GetLength());
            Radians=(double)i*6.28/12.0;//弧度数
            x=xStart-(size.cx/2)+
                (int)((double)((rc.right-rc.left-30)/2)*sin(Radians));
            y=yStart-( size.cy/2)-
                (int)((double)((rc.right-rc.left-30)/2)*cos(Radians));
            pDC->ExtTextOut( x, y, ETO_CLIPPED  ,NULL,strDigits,strDigits.GetLength(),NULL );
        }
        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,0,0));
        pDC->SelectObject(&HourPen);
        pDC->MoveTo(xStart,yStart);
        pDC->LineTo(xStart+(int)((double)((rc.right-rc.left-30)/2/3) *sin(Radians)),
            yStart-(int)((double)(((rc.bottom-rc.top-30)/2)/3)*cos(Radians)));
        Radians=(double)time.GetMinute()+(double)time.GetSecond()/60.0;
        Radians*=6.28/60.0;
        CPen MinutePen(PS_SOLID,3,RGB(0,0,0));
        pDC->SelectObject(&MinutePen);
        pDC->MoveTo(xStart,yStart);
        pDC->LineTo(xStart+(int)((double)(((rc.right-rc.left-30)/2*2)/3)*sin(Radians)),
            yStart-(int)((double)((((rc.bottom-rc.top-30)/2)*2)/3)*cos(Radians)));
        Radians=(double)time.GetSecond();
        Radians*=6.28/60.0;
        CPen SecondPen(PS_SOLID,1,RGB(0,0,0));
    
        pDC->SelectObject(&SecondPen);
        pDC->MoveTo(xStart,yStart);
        pDC->LineTo(xStart+(int)((double)(((rc.right-rc.left-30)/2*4)/5)*sin(Radians)),
            yStart-(int)((double)((((rc.bottom-rc.top-30)/2)*4)/5)*cos(Radians)));
        pDC->SelectObject(pOldPen);
  • 相关阅读:
    怎样从外网访问内网Django?
    怎样从外网访问内网Jboss?
    怎样从外网访问内网php-fpm?
    python中关于发邮件的示例
    python中关于局部变量与全局变量的认识
    python实现二分查找与冒泡排序
    自动化测试框架中关于selenium api的二次封装
    python 的日志相关应用
    python中关于字符串的操作
    EBS 物料单位换算
  • 原文地址:https://www.cnblogs.com/sankye/p/2936428.html
Copyright © 2011-2022 走看看