| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 489 人关注过本帖
标题:求注释吡表示看不懂
只看楼主 加入收藏
lcx529
Rank: 1
等 级:新手上路
帖 子:4
专家分:1
注 册:2013-12-22
结帖率:0
收藏
已结贴  问题点数:20 回复次数: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:52
so_love
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:7
帖 子:812
专家分:4151
注 册:2013-11-25
收藏
得分:7 
.....

一花一世界、一叶一追寻、片片花叶落、情系何人身。
2014-01-01 10:20
domoke
Rank: 2
等 级:论坛游民
帖 子:36
专家分:71
注 册:2013-9-11
收藏
得分:7 
看不懂就对了
2014-01-01 13:11
xiaozi2013
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:四川成都
等 级:蒙面侠
威 望:6
帖 子:830
专家分:4331
注 册:2013-12-13
收藏
得分:7 
以下是引用domoke在2014-1-1 13:11:10的发言:

看不懂就对了




---------表示也看不不懂-------------

--整天敲那些破代码能找着媳妇儿吗。。。---
2014-01-01 13:36
快速回复:求注释吡表示看不懂
数据加载中...
 
   



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

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