Exemplo n.º 1
0
/******************************************************************
 *
 *  WndProc
 *
 ******************************************************************/
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case WM_CREATE:
        // Start with non-coalescable timer.
        // Later we switch to the coalescable timer.
        gTimerRec[TIMERID_NOCOALSCING].lLast = GetPerformanceCounter();
        if (!SetCoalescableTimer(hwnd, TIMERID_NOCOALSCING, TIMER_ELAPSE, NULL, TIMERV_NO_COALESCING)) {
            return -1;
        }

        // Let's update the screen periodically.
        SetTimer(hwnd, TIMERID_UPDATE_SCREEN, TIMER_AUTO_REFRESH_ELAPSE, NULL);
        return 0;

    case WM_TIMER:
        if (wParam < ARRAYSIZE(gTimerRec)) {

            TimerHandler(hwnd, (UINT_PTR)wParam);

        } else if (wParam == TIMERID_UPDATE_SCREEN) {
            // Periodically update the results.
    case WM_MOUSEMOVE:  // Tricky: also update the screen at every mouse move.
            InvalidateRect(hwnd, NULL, FALSE);
        }
        break;

    case WM_PAINT:
    case WM_DISPLAYCHANGE:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hwnd, &ps);
            OnPaint(hdc, &ps.rcPaint);
            EndPaint(hwnd, &ps);
        }
        return 0;

    case WM_KEYDOWN:
        if (wParam == VK_SPACE) {
            // Space key to power down the monitor.
            DefWindowProc(GetDesktopWindow(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);
        }
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        return 1;
    }

    return DefWindowProc(hwnd, message, wParam, lParam);
}
Exemplo n.º 2
0
//添加一次性的定时
unsigned int ScriptTimerMgr::AddTimerOnce_Callback(ITimerCallback* callback,
		float fInterval)
{
	if (!callback)
		return 0;

	OBJID nId = getNextGuid();

	m_mapHandler.insert(make_pair(TimerID(nId, true), TimerHandler(callback)));

	m_pkTimerMgr->SetTimer(this, nId, fInterval);

	return nId;
}
Exemplo n.º 3
0
//添加一次性的脚本定时
unsigned int ScriptTimerMgr::AddTimerOnce_Lua(LuaObject func, float fInterval)
{
	if (!func.IsFunction())
	{
		return 0;
	}

	OBJID nId = getNextGuid();

	m_mapHandler.insert(make_pair(TimerID(nId, true), TimerHandler(func)));

	m_pkTimerMgr->SetTimer(this, nId, fInterval);

	return nId;
}
Exemplo n.º 4
0
void interrupt VectorNumber_Vtpm2ch0 Timer1_ISR(void)
{
    TimerHandler();
}
Exemplo n.º 5
0
void interrupt VectorNumber_Vtpm2ovf Timer_ISR(void)
{
    TimerHandler();
}