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.

140 lines
3.9 KiB

  1. // TestSettingsCtrl.h : Declaration of the CTestSettingsCtrl
  2. #pragma once
  3. #include "resource.h" // main symbols
  4. #include <atlctl.h>
  5. #include <set>
  6. #include "AddIn.h"
  7. // CTestSettingsCtrl
  8. class ATL_NO_VTABLE CTestSettingsCtrl :
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. public IDispatchImpl<ITestSettingsCtrl, &IID_ITestSettingsCtrl, &LIBID_AppVerifierLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
  11. public IPersistStreamInitImpl<CTestSettingsCtrl>,
  12. public IOleControlImpl<CTestSettingsCtrl>,
  13. public IOleObjectImpl<CTestSettingsCtrl>,
  14. public IOleInPlaceActiveObjectImpl<CTestSettingsCtrl>,
  15. public IViewObjectExImpl<CTestSettingsCtrl>,
  16. public IOleInPlaceObjectWindowlessImpl<CTestSettingsCtrl>,
  17. public CComCoClass<CTestSettingsCtrl, &CLSID_TestSettingsCtrl>,
  18. public CComCompositeControl<CTestSettingsCtrl>
  19. {
  20. public:
  21. CTestSettingsCtrl()
  22. {
  23. m_bLVCreated = FALSE;
  24. m_bWindowOnly = TRUE;
  25. CalcExtent(m_sizeExtent);
  26. }
  27. virtual HWND CreateControlWindow(HWND hWndParent, RECT& rcPos);
  28. DECLARE_REGISTRY_RESOURCEID(IDR_TESTSETTINGSCTRL)
  29. BEGIN_COM_MAP(CTestSettingsCtrl)
  30. COM_INTERFACE_ENTRY(ITestSettingsCtrl)
  31. COM_INTERFACE_ENTRY(IDispatch)
  32. COM_INTERFACE_ENTRY(IViewObjectEx)
  33. COM_INTERFACE_ENTRY(IViewObject2)
  34. COM_INTERFACE_ENTRY(IViewObject)
  35. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  36. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  37. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  38. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  39. COM_INTERFACE_ENTRY(IOleControl)
  40. COM_INTERFACE_ENTRY(IOleObject)
  41. COM_INTERFACE_ENTRY(IPersistStreamInit)
  42. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  43. END_COM_MAP()
  44. BEGIN_PROP_MAP(CTestSettingsCtrl)
  45. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  46. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  47. // Example entries
  48. // PROP_ENTRY("Property Description", dispid, clsid)
  49. // PROP_PAGE(CLSID_StockColorPage)
  50. END_PROP_MAP()
  51. BEGIN_MSG_MAP(CTestSettingsCtrl)
  52. MESSAGE_HANDLER(WM_SIZE, OnSize)
  53. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  54. MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
  55. CHAIN_MSG_MAP(CComCompositeControl<CTestSettingsCtrl>)
  56. END_MSG_MAP()
  57. // Handler prototypes:
  58. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  59. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  60. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  61. LRESULT OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  62. BEGIN_SINK_MAP(CTestSettingsCtrl)
  63. //Make sure the Event Handlers have __stdcall calling convention
  64. END_SINK_MAP()
  65. STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
  66. {
  67. if (dispid == DISPID_AMBIENT_BACKCOLOR)
  68. {
  69. SetBackgroundColorFromAmbient();
  70. FireViewChange();
  71. }
  72. return IOleControlImpl<CTestSettingsCtrl>::OnAmbientPropertyChange(dispid);
  73. }
  74. // IViewObjectEx
  75. DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
  76. // ITestSettingsCtrl
  77. enum { IDD = IDD_TESTSETTINGSCTRL };
  78. DECLARE_PROTECT_FINAL_CONSTRUCT()
  79. HRESULT FinalConstruct()
  80. {
  81. return S_OK;
  82. }
  83. void FinalRelease()
  84. {
  85. }
  86. BOOL m_bLVCreated;
  87. BOOL CheckForConflictingTests(
  88. IN HWND hWndListView,
  89. IN LPCWSTR pwszTestName
  90. );
  91. BOOL CheckForRunAlone(
  92. IN HWND hWndListView,
  93. IN CTestInfo* pTest
  94. );
  95. void DisplayRunAloneError(
  96. IN LPCWSTR pwszTestName
  97. );
  98. #define CHECK_BIT(x) ((x >> 12) - 1)
  99. #define CHECK_CHANGED(pNMListView) \
  100. (CHECK_BIT(pNMListView->uNewState) ^ CHECK_BIT(pNMListView->uOldState))
  101. BOOL IsChecked(
  102. NM_LISTVIEW* pNMListView
  103. );
  104. BOOL CheckChanged(
  105. NM_LISTVIEW* pNMListView
  106. );
  107. };
  108. struct CompareTests
  109. {
  110. bool operator()(const CTestInfo* p1, const CTestInfo* p2) const
  111. {
  112. return p1 < p2;
  113. }
  114. };
  115. extern std::set<CTestInfo*, CompareTests>* g_psTests;