Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.1 KiB

  1. //=================================================================
  2. //
  3. // WinMsgEvent.h --
  4. //
  5. // Copyright � Microsoft Corporation. All rights reserved.
  6. //
  7. //=================================================================
  8. #ifndef _WBEM_MESSAGE_EVENT_FORWARDER_H
  9. #define _WBEM_MESSAGE_EVENT_FORWARDER_H
  10. using namespace std;
  11. #define MSGWINDOWNAME TEXT("WinMsgEventProvider")
  12. //
  13. class POLARITY CAutoEvent
  14. {
  15. HANDLE m_hEvent ;
  16. public:
  17. CAutoEvent() { m_hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); };
  18. ~CAutoEvent() { CloseHandle( m_hEvent ); };
  19. DWORD Wait( DWORD a_dwMillSec ) { return WaitForSingleObject( m_hEvent, a_dwMillSec ); };
  20. BOOL Signal() { return SetEvent( m_hEvent ); };
  21. };
  22. //
  23. class POLARITY CWinMsgEvent
  24. {
  25. private:
  26. static CCritSec mg_csMapLock ;
  27. static CCritSec mg_csWindowLock ;
  28. static CAutoEvent mg_aeCreateWindow ;
  29. typedef std::multimap<UINT, CWinMsgEvent*> Sink_Map ;
  30. static Sink_Map mg_oSinkMap ;
  31. static HANDLE mg_hThreadPumpHandle ;
  32. static HWND mg_hWnd ;
  33. static void HandleEvent( DWORD a_dwPowerEvent, DWORD a_dwData ) ;
  34. static void CreateMsgProvider() ;
  35. static HWND CreateMsgWindow() ;
  36. static void DestroyMsgWindow() ;
  37. static void WindowsDispatch() ;
  38. static LRESULT CALLBACK MsgWndProc(
  39. IN HWND a_hWnd,
  40. IN UINT a_message,
  41. IN WPARAM a_wParam,
  42. IN LPARAM a_lParam ) ;
  43. static DWORD WINAPI dwThreadProc( LPVOID lpParameter );
  44. static BOOL WINAPI CtrlHandlerRoutine( DWORD dwCtrlType ) ;
  45. protected:
  46. void RegisterForMessage(
  47. IN UINT a_message
  48. ) ;
  49. bool UnRegisterMessage(
  50. IN UINT a_message
  51. ) ;
  52. void UnRegisterAllMessages() ;
  53. public:
  54. CWinMsgEvent () ;
  55. ~CWinMsgEvent () ;
  56. enum E_ReturnAction {
  57. e_DefProc, // call DefWindowProc
  58. e_ReturnResult // return msg with WinMsgEvent() LRESULT
  59. };
  60. virtual void WinMsgEvent(
  61. IN HWND a_hWnd,
  62. IN UINT a_message,
  63. IN WPARAM a_wParam,
  64. IN LPARAM a_lParam,
  65. OUT E_ReturnAction &eRetAction,
  66. OUT LRESULT &a_lResult
  67. ) = 0 ;
  68. };
  69. #endif // _WBEM_MESSAGE_EVENT_FORWARDER_H