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.

155 lines
4.2 KiB

  1. //==============================================================;
  2. //
  3. // This source code is only intended as a supplement to existing Microsoft documentation.
  4. //
  5. //
  6. //
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  9. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  10. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  11. // PURPOSE.
  12. //
  13. // Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  14. //
  15. //
  16. //
  17. //==============================================================;
  18. // MMCControl.h : Declaration of the CMMCControl
  19. #ifndef __MMCCONTROL_H_
  20. #define __MMCCONTROL_H_
  21. #include "resource.h" // main symbols
  22. #include <atlctl.h>
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMMCControl
  25. class ATL_NO_VTABLE CMMCControl :
  26. public CComObjectRootEx<CComSingleThreadModel>,
  27. public IDispatchImpl<IMMCControl, &IID_IMMCControl, &LIBID_ATLCONTROLLib>,
  28. public CComCompositeControl<CMMCControl>,
  29. public IPersistStreamInitImpl<CMMCControl>,
  30. public IOleControlImpl<CMMCControl>,
  31. public IOleObjectImpl<CMMCControl>,
  32. public IOleInPlaceActiveObjectImpl<CMMCControl>,
  33. public IViewObjectExImpl<CMMCControl>,
  34. public IOleInPlaceObjectWindowlessImpl<CMMCControl>,
  35. public ISupportErrorInfo,
  36. public CComCoClass<CMMCControl, &CLSID_MMCControl>
  37. {
  38. public:
  39. CMMCControl()
  40. {
  41. OutputDebugString(_TEXT("CMMCControl constructor\n"));
  42. m_bWindowOnly = TRUE;
  43. m_bAnimating = FALSE;
  44. CalcExtent(m_sizeExtent);
  45. }
  46. ~CMMCControl()
  47. {
  48. OutputDebugString(_TEXT("CMMCControl destructor\n"));
  49. }
  50. DECLARE_REGISTRY_RESOURCEID(IDR_MMCCONTROL)
  51. DECLARE_NOT_AGGREGATABLE(CMMCControl)
  52. DECLARE_PROTECT_FINAL_CONSTRUCT()
  53. BEGIN_COM_MAP(CMMCControl)
  54. COM_INTERFACE_ENTRY(IMMCControl)
  55. COM_INTERFACE_ENTRY(IDispatch)
  56. COM_INTERFACE_ENTRY(IViewObjectEx)
  57. COM_INTERFACE_ENTRY(IViewObject2)
  58. COM_INTERFACE_ENTRY(IViewObject)
  59. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  60. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  61. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  62. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  63. COM_INTERFACE_ENTRY(IOleControl)
  64. COM_INTERFACE_ENTRY(IOleObject)
  65. COM_INTERFACE_ENTRY(IPersistStreamInit)
  66. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  67. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  68. END_COM_MAP()
  69. BEGIN_PROP_MAP(CMMCControl)
  70. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  71. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  72. // Example entries
  73. // PROP_ENTRY("Property Description", dispid, clsid)
  74. // PROP_PAGE(CLSID_StockColorPage)
  75. END_PROP_MAP()
  76. BEGIN_MSG_MAP(CMMCControl)
  77. CHAIN_MSG_MAP(CComCompositeControl<CMMCControl>)
  78. COMMAND_HANDLER(IDC_ANIMATE, BN_CLICKED, OnClickedAnimate)
  79. END_MSG_MAP()
  80. // Handler prototypes:
  81. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  82. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  83. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  84. BEGIN_SINK_MAP(CMMCControl)
  85. //Make sure the Event Handlers have __stdcall calling convention
  86. END_SINK_MAP()
  87. STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
  88. {
  89. if (dispid == DISPID_AMBIENT_BACKCOLOR)
  90. {
  91. SetBackgroundColorFromAmbient();
  92. FireViewChange();
  93. }
  94. return IOleControlImpl<CMMCControl>::OnAmbientPropertyChange(dispid);
  95. }
  96. // ISupportsErrorInfo
  97. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
  98. {
  99. static const IID* arr[] =
  100. {
  101. &IID_IMMCControl,
  102. };
  103. for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
  104. {
  105. if (::InlineIsEqualGUID(*arr[i], riid))
  106. return S_OK;
  107. }
  108. return S_FALSE;
  109. }
  110. // IViewObjectEx
  111. DECLARE_VIEW_STATUS(0)
  112. // IMMCControl
  113. public:
  114. STDMETHOD(DoHelp)();
  115. STDMETHOD(StopAnimation)();
  116. STDMETHOD(StartAnimation)();
  117. enum { IDD = IDD_MMCCONTROL };
  118. LRESULT OnClickedAnimate(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  119. {
  120. m_bAnimating = !m_bAnimating;
  121. if (m_bAnimating)
  122. StartAnimation();
  123. else
  124. StopAnimation();
  125. return 0;
  126. }
  127. private:
  128. BOOL m_bAnimating;
  129. UINT m_timerId;
  130. };
  131. #endif //__MMCCONTROL_H_