diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/vmpi/testapps/MessageWatch/win_idle.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/vmpi/testapps/MessageWatch/win_idle.h')
| -rw-r--r-- | utils/vmpi/testapps/MessageWatch/win_idle.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/vmpi/testapps/MessageWatch/win_idle.h b/utils/vmpi/testapps/MessageWatch/win_idle.h new file mode 100644 index 0000000..6e2e3f3 --- /dev/null +++ b/utils/vmpi/testapps/MessageWatch/win_idle.h @@ -0,0 +1,78 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// WinIdle.h - Defines a class for sending idle messages to a window from a secondary thread + +#ifndef __WINIDLE_H__ +#define __WINIDLE_H__ + + +class CWinIdle +{ +protected: + HANDLE m_hIdleEvent, m_hStopEvent; + + HWND m_hWnd; + UINT m_uMsg; + WPARAM m_wParam; + LPARAM m_lParam; + + DWORD m_dwDelay; + + HANDLE m_hIdleThread; + + // The thread calling stub + static DWORD WINAPI ThreadStub(LPVOID pIdle); + // The actual idle loop + virtual DWORD RunIdle(); + +public: + CWinIdle(); + virtual ~CWinIdle(); + + inline DWORD GetDelay() {return m_dwDelay;} + inline void SetDelay(DWORD delay) {m_dwDelay = delay;} + + // Member access + virtual HANDLE GetThreadHandle() const { return m_hIdleThread; }; + + // Start idling, and define the message and window to use + // Returns TRUE on success + virtual BOOL StartIdle(HWND hWnd, UINT uMessage, WPARAM wParam = 0, LPARAM lParam = 0, DWORD dwDelay = 0); + // Stop idling + // Returns TRUE on success + virtual BOOL EndIdle(); + // Notify the idle process that the message was received. + // Note : If this function is not called, the idle thread will not send any messages + virtual void NextIdle(); +}; + + +// Used to slow down the idle thread while dialogs are up. +class IdleChanger +{ +public: + IdleChanger(CWinIdle *pIdle, DWORD msDelay) + { + m_pIdle = pIdle; + m_OldDelay = pIdle->GetDelay(); + pIdle->SetDelay(msDelay); + } + + ~IdleChanger() + { + m_pIdle->SetDelay(m_OldDelay); + } + + CWinIdle *m_pIdle; + DWORD m_OldDelay; +}; + + + +#endif //__WINIDLE_H__ + |