• 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);
  • 相关阅读:
    android-support-v4.jar 免积分下载
    Android canvast View 代码实例
    Android recording 录音功能 简单使用小实例
    android progressdialog 对话框试用实例
    Android 视频 教程 源码 电子书 网址
    android Notification
    Zookeeper 基本应用及盲点
    Mysql 死锁分析学习
    Mysql 学习总结
    数据库事务的本质
  • 原文地址:https://www.cnblogs.com/sankye/p/2936428.html
Copyright © 2020-2023  润新知