프로그래밍/API

유휴시간에 실행하기

에어버스 2016. 1. 16. 22:42

프로그램 유휴 시간에 작업하기
프로그램이 쉴때 25번 줄에 작업할 함수를 넣으면 된다. 타이머보다는 이게 효율적일듯함.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    // 기본 메시지 루프입니다.
    /*
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    */
    while (TRUE)
    {
        if (PeekMessage(&msg, nullptr, 00, PM_REMOVE)) // 메시지 큐에 메시지가 없으면 FALSE 리턴 
        {
            if (msg.message == WM_QUIT)
                break;
            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
        else
            DrawRectangle(hWnd1); // 아무런 메시지 없을때 실행
    }
cs