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.

89 lines
2.1 KiB

  1. // Events.h: Definition of the FooBarEvents class
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(__EVENTS_H__06E192AB_5CAD_11D1_B670_00A024E430AB__INCLUDED_)
  5. #define __EVENTS_H__06E192AB_5CAD_11D1_B670_00A024E430AB__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #include "resource.h" // main symbols
  10. #include "shimgvw.h"
  11. /////////////////////////////////////////////////////////////////////////////
  12. // FooBarEvents
  13. class CEvents
  14. {
  15. public:
  16. virtual void OnClose()
  17. {}
  18. virtual void OnPreviewReady()
  19. {}
  20. virtual void OnError()
  21. {}
  22. virtual void OnChangeUI()
  23. {}
  24. virtual void OnBestFitPress()
  25. {}
  26. virtual void OnActualSizePress()
  27. {}
  28. };
  29. template <class T>
  30. class CControlEvents : public CEvents,
  31. public IConnectionPointImpl<T, &DIID_DPreviewEvents, CComDynamicUnkArray>
  32. {
  33. protected:
  34. void _FireEvent( DWORD dwID, DISPPARAMS *pdisp = NULL )
  35. {
  36. T* pT = (T*)this;
  37. pT->Lock();
  38. IUnknown** pp = m_vec.begin();
  39. while (pp < m_vec.end())
  40. {
  41. if (*pp != NULL)
  42. {
  43. DISPPARAMS disp = { NULL, NULL, 0, 0 };
  44. if ( !pdisp )
  45. pdisp = &disp;
  46. IDispatch* pDispatch = reinterpret_cast<IDispatch*>(*pp);
  47. pDispatch->Invoke(dwID, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, pdisp, NULL, NULL, NULL);
  48. }
  49. pp++;
  50. }
  51. pT->Unlock();
  52. }
  53. };
  54. template <class T>
  55. class CPreviewEvents : public CControlEvents<T>
  56. {
  57. public:
  58. virtual void OnClose()
  59. {
  60. _FireEvent( 0x1 );
  61. }
  62. virtual void OnPreviewReady()
  63. {
  64. _FireEvent( 0x2 );
  65. }
  66. virtual void OnError()
  67. {
  68. _FireEvent( 0x3 );
  69. }
  70. virtual void OnBestFitPress()
  71. {
  72. _FireEvent( 0x4 );
  73. }
  74. virtual void OnActualSizePress()
  75. {
  76. _FireEvent( 0x5 );
  77. }
  78. };
  79. #endif // !defined(__EVENTS_H__06E192AB_5CAD_11D1_B670_00A024E430AB__INCLUDED_)