Exemple #1
0
void DrawTime(HWND hwnd, HBRUSH hBrushRed) {
    PAINTSTRUCT ps;
    HDC hdc;
    
    hdc = BeginPaint(hwnd, &ps);
    SetMapMode(hdc, MM_ISOTROPIC);

    SetWindowExtEx(hdc, WINDOW_WIDTH, WINDOW_HEIGHT, NULL);
    SetViewportExtEx(hdc, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, NULL);

    SelectObject(hdc, GetStockObject(NULL_PEN));
    SelectObject(hdc, hBrushRed);
    SetBkMode(hdc, TRANSPARENT);
    if (n_chess % 2 + 1 == 1) {
        SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);

        _DisplayTime(hwnd, hdc);

        SetViewportOrgEx(hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);
        
        DisplayTwoDigits(hdc, 0, FALSE);
        DisplayColon(hdc);
        DisplayTwoDigits(hdc, 0, FALSE);
    } else {
        SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);
        DisplayTwoDigits(hdc, 0, FALSE);
        DisplayColon(hdc) ;
        DisplayTwoDigits(hdc, 0, FALSE);

        SetViewportOrgEx (hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);

        _DisplayTime(hwnd, hdc);
    }
    EndPaint(hwnd,&ps);
}
Exemple #2
0
void DisplayTime (HDC hdc, BOOL f24Hour, BOOL fSuppress)
{
	SYSTEMTIME st ;
	GetLocalTime (&st) ;
	if (f24Hour)
		DisplayTwoDigits (hdc, st.wHour, fSuppress) ;
	else
		DisplayTwoDigits (hdc, (st.wHour %= 12) ? st.wHour : 12, fSuppress) ;
	if (st.wSecond % 2 == 0)
	{
		DisplayColon (hdc) ;
	}
	else
	{
		DisplayBlank(hdc);
	}
	DisplayTwoDigits (hdc, st.wMinute, FALSE) ;
	if (st.wSecond % 2 != 0)
	{
		DisplayColon (hdc) ;
	}
	else
	{
		DisplayBlank(hdc);
	}
	DisplayTwoDigits (hdc, st.wSecond, FALSE) ;
}
Exemple #3
0
void _DisplayTime(HWND hwnd, HDC hdc) {
	if (n_chess & 1) {
		t2_sec = t2_sec - 0.5;
		if (t2_sec == 0) {
            if (t2_min == 0) {
                /* Print the winer on the screen */
                is_pause = !is_pause;
                MessageBox(hwnd, "时间到!", "提示", MB_OK);
                draw_result(hwnd, PLAYER1);
            } else {
                --t2_min;
			    t2_sec = 59;
            }
		}

        DisplayTwoDigits(hdc, t2_min, FALSE);
		DisplayColon(hdc);
		DisplayTwoDigits(hdc, t2_sec, FALSE);
	} else {
        t1_sec = t1_sec - 0.5;
		if (t1_sec == 0){
            if (t1_min == 0) {
                /* Print the winer on the screen */
                is_pause = !is_pause;
                MessageBox(hwnd, "时间到!", "提示", MB_OK);
                draw_result(hwnd, PLAYER2);
            } else {
                --t1_min;
                t1_sec = 59;
            }
             
        }

        DisplayTwoDigits(hdc, t1_min, FALSE);
		DisplayColon(hdc);
		DisplayTwoDigits(hdc, t1_sec, FALSE);
	}
}