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.

138 lines
3.4 KiB

  1. #ifndef __TVINTF_H_
  2. #define __TVINTF_H_
  3. /*++
  4. Copyright (c) Microsoft Corporation
  5. Module Name:
  6. tvintf.h
  7. Abstract:
  8. header file to define interfaces between Device Manager snapin
  9. and TreeView OCX.
  10. Author:
  11. William Hsieh (williamh) created
  12. Revision History:
  13. --*/
  14. // Interface designed for snapin to connect/disconnect, control, retreive
  15. // information to/from the Tree view ocx.
  16. class IDMTVOCX : public IUnknown
  17. {
  18. public: virtual HTREEITEM InsertItem(LPTV_INSERTSTRUCT pis) = 0;
  19. public: virtual HRESULT DeleteItem(HTREEITEM hItem) = 0;
  20. public: virtual HRESULT DeleteAllItems() = 0;
  21. public: virtual HIMAGELIST SetImageList(INT iImage, HIMAGELIST himl) = 0;
  22. public: virtual HRESULT SetItem(TV_ITEM* pitem) = 0;
  23. public: virtual HRESULT Expand(UINT Flags, HTREEITEM htiem) = 0;
  24. public: virtual HRESULT SelectItem(UINT Flags, HTREEITEM hitem) = 0;
  25. public: virtual HRESULT SetStyle(DWORD dwStyle) = 0;
  26. public: virtual HWND GetWindowHandle() = 0;
  27. public: virtual HRESULT GetItem(TV_ITEM* pti) = 0;
  28. public: virtual HTREEITEM GetNextItem(UINT Flags, HTREEITEM htiRef) = 0;
  29. public: virtual HRESULT SelectItem(HTREEITEM hti) = 0;
  30. public: virtual UINT GetCount() = 0;
  31. public: virtual HTREEITEM GetSelectedItem() = 0;
  32. public: virtual HRESULT Connect(IComponent* pIComponent, MMC_COOKIE cookie) = 0;
  33. public: virtual HRESULT SetActiveConnection(MMC_COOKIE cookie) = 0;
  34. public: virtual MMC_COOKIE GetActiveConnection() = 0;
  35. public: virtual HRESULT SetRedraw(BOOL Redraw) = 0;
  36. public: virtual BOOL EnsureVisible(HTREEITEM hitem) = 0;
  37. };
  38. typedef enum tagTvNotifyCode
  39. {
  40. TV_NOTIFY_CODE_CLICK = 0,
  41. TV_NOTIFY_CODE_DBLCLK,
  42. TV_NOTIFY_CODE_RCLICK,
  43. TV_NOTIFY_CODE_RDBLCLK,
  44. TV_NOTIFY_CODE_KEYDOWN,
  45. TV_NOTIFY_CODE_CONTEXTMENU,
  46. TV_NOTIFY_CODE_EXPANDING,
  47. TV_NOTIFY_CODE_EXPANDED,
  48. TV_NOTIFY_CODE_SELCHANGING,
  49. TV_NOTIFY_CODE_SELCHANGED,
  50. TV_NOTIFY_CODE_GETDISPINFO,
  51. TV_NOTIFY_CODE_FOCUSCHANGED,
  52. TV_NOTIFY_CODE_UNKNOWN
  53. } TV_NOTIFY_CODE, *PTV_NOTIFY_CODE;
  54. // interface DECLSPEC_UUID("8e0ba98a-d161-11d0-8353-00a0c90640bf")
  55. class ISnapinCallback : public IUnknown
  56. {
  57. public:
  58. virtual HRESULT STDMETHODCALLTYPE tvNotify(HWND hwndTV, MMC_COOKIE cookie,
  59. TV_NOTIFY_CODE Code,
  60. LPARAM arg, LPARAM param) = 0;
  61. };
  62. extern const IID IID_ISnapinCallback;
  63. extern const IID IID_IDMTVOCX;
  64. template<class ISome>
  65. class SafeInterfacePtr
  66. {
  67. public:
  68. SafeInterfacePtr(ISome* pInterface = NULL)
  69. {
  70. m_pISome = pInterface;
  71. if (m_pISome)
  72. m_pISome->AddRef();
  73. }
  74. ~SafeInterfacePtr()
  75. {
  76. SafeRelease();
  77. }
  78. void SafeRelease()
  79. {
  80. if (m_pISome)
  81. {
  82. m_pISome->Release();
  83. m_pISome = NULL;
  84. }
  85. }
  86. void Attach(ISome* pInterface)
  87. {
  88. ASSERT(!m_pISome);
  89. ASSERT(pInterface);
  90. m_pISome = pInterface;
  91. m_pISome->AddRef();
  92. }
  93. void Detach()
  94. {
  95. ASSERT(m_pISome);
  96. m_pISome->Release();
  97. m_pISome = NULL;
  98. }
  99. ISome* operator->()
  100. {
  101. return m_pISome;
  102. }
  103. ISome& operator*()
  104. {
  105. return *m_pISome;
  106. }
  107. operator ISome*()
  108. {
  109. return m_pISome;
  110. }
  111. ISome ** operator&()
  112. {
  113. return &m_pISome;
  114. }
  115. private:
  116. ISome* m_pISome;
  117. };
  118. #endif //__TVINTF_H_