| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 497 人关注过本帖
标题:求高手给注释,谢了
只看楼主 加入收藏
lcx529
Rank: 1
等 级:新手上路
帖 子:4
专家分:1
注 册:2013-12-22
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
求高手给注释,谢了
#define _CRT_SECURE_NO_WARNINGS

#include <windows.h>

#include <math.h>

#include <time.h>

#pragma comment(lib, "user32.lib")

#pragma comment(lib, "gdi32.lib")

#pragma comment(linker, "/SUBSYSTEM:Windows")

  

void GetPos(double degree, int len, int* x, int* y)

{

    *x = len * sin(degree);

    *y = len * cos(degree);

}

  

void DrawClock(HWND hw, HDC h, int hour, int minute, int second)

{

    HDC bufdc = CreateCompatibleDC(h);

    HBITMAP buf = CreateCompatibleBitmap(bufdc, 200, 200);

    RECT cr;

    HBRUSH bBg = CreateSolidBrush(RGB(255, 255, 255));

    GetClientRect(hw, &cr);

    SelectObject(bufdc, bBg);

    SelectObject(bufdc, buf);

    FillRect(bufdc, &cr, bBg);

  

    {

        int sx, sy, ex, ey;

        int i;

        for(i = 0; i < 12; ++i) {

            GetPos(2*3.14159/12*i, 85, &sx, &sy);

            GetPos(2*3.14159/12*i, 95, &ex, &ey);

            MoveToEx(bufdc, 100+sx, 100-sy, 0);

            LineTo(bufdc, 100+ex, 100-ey);

        }

    }

  

    {

        int hx, hy, mx, my, sx, sy;

        GetPos(2*3.14159 / 12 * (hour + (double)minute / 60 + (double)second / 3600), 50, &hx, &hy);

        GetPos(2*3.14159 / 60 * (minute + (double)second / 60), 65, &mx, &my);

        GetPos(2*3.14159 / 60 * second, 80, &sx, &sy);

        MoveToEx(bufdc, 100, 100, NULL);

        LineTo(bufdc, 100+hx, 100-hy);

        MoveToEx(bufdc, 100, 100, NULL);

        LineTo(bufdc, 100+mx, 100-my);

        MoveToEx(bufdc, 100, 100, NULL);

        LineTo(bufdc, 100+sx, 100-sy);

    }

      

    BitBlt(h, 0, 0, 200, 200, bufdc, 0, 0, SRCCOPY);

    DeleteDC(bufdc);

    DeleteObject(bBg);

    DeleteObject(buf);

}

  

LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l)

{

    switch(m) {

        case WM_CREATE:

            SetTimer(h, 1, 1000, 0);

            return 0;

        case WM_ERASEBKGND:

            return 1;

        case WM_TIMER:

            InvalidateRect(h, 0, FALSE);

            return 0;

        case WM_PAINT: {

            PAINTSTRUCT ps;

            HDC dc = BeginPaint(h, &ps);

            {

                time_t t;

                struct tm* pst;

                time(&t);

                pst = localtime(&t);

                DrawClock(h, dc, pst->tm_hour, pst->tm_min, pst->tm_sec);

            }

            EndPaint(h, &ps);

            return 0;

        }

        case WM_DESTROY:

            KillTimer(h, 1);

            PostQuitMessage(0);

            return 0;

        default:

            return DefWindowProc(h, m, w, l);

    }

}

  

int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmd, INT nShow)

{

    WNDCLASS wc;

    ZeroMemory(&wc, sizeof(wc));

    wc.style = CS_HREDRAW | CS_VREDRAW;

    wc.lpfnWndProc = WndProc;

    wc.hInstance = hInst;

    wc.hbrBackground = (HBRUSH) COLOR_WINDOW;

    wc.lpszClassName = TEXT("MYCLOCK");

      

    if (RegisterClass(&wc) != 0) {

        MSG m;

        HWND hw = CreateWindow(TEXT("MYCLOCK"), TEXT("Clock"), WS_OVERLAPPEDWINDOW,

            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, 0);

         

        if (hw != NULL) {

            RECT r;

            GetWindowRect(hw, &r);

            r.right = r.left + 200;

            r.bottom = r.top + 200;

            AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, FALSE);

            MoveWindow(hw, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);

            ShowWindow(hw, SW_SHOWNORMAL);

            UpdateWindow(hw);

         

            while( GetMessage(&m, 0, 0, 0) > 0) {

                TranslateMessage(&m);

                DispatchMessage(&m);

            }

            return 0;

        }

        return 1;

    } else

        return 1;
}
搜索更多相关主题的帖子: Windows comment include double minute 
2013-12-31 17:56
lcx529
Rank: 1
等 级:新手上路
帖 子:4
专家分:1
注 册:2013-12-22
收藏
得分:0 
..
2013-12-31 20:35
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:10 
拿来编译运行一下不久知道了?
没有咩可以解析的,就是看函数名,变量名,应该大概知道究竟

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2014-01-01 10:31
ravenhu13
Rank: 2
等 级:新手上路
威 望:3
帖 子:4
专家分:0
注 册:2014-2-3
收藏
得分:0 
绘图的吧,你自己逐个查名就知道了。
2014-02-04 00:10
快速回复:求高手给注释,谢了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.037315 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved