Source code of Windows XP (NT5)
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.

370 lines
10 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. proppage.h
  7. Implementation for property pages in MMC
  8. FILE HISTORY:
  9. */
  10. #ifndef _PROPPAGE_H
  11. #define _PROPPAGE_H
  12. // proppage.h : header file
  13. //
  14. #include "afxdlgs.h"
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // FORWARD DECLARATIONS
  17. class CPropertyPageBase;
  18. typedef CList< CPropertyPageBase*, CPropertyPageBase* > CPropertyPageBaseList;
  19. HWND FindMMCMainWindow();
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CPropertyPageHolderBase
  22. class CPropertyPageHolderBase
  23. {
  24. public:
  25. // construction
  26. // for scope pane property pages and wizards
  27. CPropertyPageHolderBase(ITFSNode * pNode,
  28. IComponentData *pComponentData,
  29. LPCTSTR pszSheetName,
  30. BOOL bIsScopePane = TRUE);
  31. // for result pane property pages only
  32. // result pane wizards should use the previous constructor
  33. CPropertyPageHolderBase(ITFSNode * pNode,
  34. IComponent * pComponent,
  35. LPCTSTR pszSheetName,
  36. BOOL bIsScopePane = FALSE);
  37. virtual ~CPropertyPageHolderBase();
  38. // initialization
  39. // common
  40. // property sheet only
  41. HRESULT CreateModelessSheet(LPPROPERTYSHEETCALLBACK pSheetCallback, LONG_PTR hConsoleHandle);
  42. // Property sheet, but do everything ourselves
  43. HRESULT DoModelessSheet();
  44. // wizard only
  45. HRESULT DoModalWizard();
  46. // helpers
  47. // common
  48. void SetSheetWindow(HWND hSheetWindow);
  49. HWND GetSheetWindow();
  50. BOOL SetDefaultSheetPos(); // sets the sheet window centered to the MMC main window
  51. void AddRef();
  52. void Release();
  53. DWORD GetRefCount();
  54. // get/set for the node we are working on
  55. ITFSNode * GetNode();
  56. void SetNode(ITFSNode* pNode);
  57. // get/set for the container we refer to
  58. ITFSNode * GetContainer();
  59. BOOL IsWizardMode();
  60. void ForceDestroy(); // forcefull shut down running sheet
  61. void AddPageToList(CPropertyPageBase* pPage);
  62. BOOL RemovePageFromList(CPropertyPageBase* pPage, BOOL bDeleteObject);
  63. // property sheet only
  64. // by WeiJiang 5/11/98, PeekMessageDuringNotifyConsole flag
  65. void EnablePeekMessageDuringNotifyConsole(BOOL bEnable)
  66. {
  67. m_bPeekMessageDuringNotifyConsole = bEnable;
  68. };
  69. DWORD NotifyConsole(CPropertyPageBase* pPage); // notify console of property changes
  70. void AcknowledgeNotify(); // acknowledge from the console
  71. virtual void OnPropertyChange(BOOL bScopePane) {}
  72. // wizard only
  73. BOOL SetWizardButtons(DWORD dwFlags);
  74. BOOL SetWizardButtonsFirst(BOOL bValid);
  75. BOOL SetWizardButtonsMiddle(BOOL bValid);
  76. BOOL SetWizardButtonsLast(BOOL bValid);
  77. BOOL PressButton(int nButton);
  78. virtual DWORD OnFinish() { return 0; }
  79. virtual BOOL OnPropertyChange(BOOL bScopePane, LONG_PTR* pChangeMask); // execute from main thread
  80. HRESULT AddPageToSheet(CPropertyPageBase* pPage);
  81. HRESULT RemovePageFromSheet(CPropertyPageBase* pPage);
  82. HWND SetActiveWindow();
  83. void IncrementDirty(int cDirty) { m_cDirty += cDirty; };
  84. BOOL IsDirty() { return m_cDirty != 0; };
  85. BOOL IsWiz97() { return m_bWiz97; }
  86. protected:
  87. // common
  88. HRESULT AddAllPagesToSheet();
  89. private:
  90. void DeleteAllPages();
  91. void FinalDestruct();
  92. // attributes
  93. protected:
  94. // by WeiJiang 5/11/98, PeekMessageDuringNotifyConsole flag
  95. BOOL m_bPeekMessageDuringNotifyConsole; // Set to FALSE by default
  96. // common
  97. CString m_stSheetTitle; // title for the sheet/wizard window
  98. CPropertyPageBaseList m_pageList; // list of property page objects
  99. BOOL m_bWizardMode; // Wizard Mode (i.e. not modeless property sheet)
  100. BOOL m_bCalledFromConsole; // console told us to put up this page
  101. BOOL m_bAutoDelete; // delete itself when refcount is zero
  102. BOOL m_bAutoDeletePages; // explicitely delete the prop pages
  103. BOOL m_bSheetPosSet;
  104. BOOL m_bWiz97;
  105. SPIComponentData m_spComponentData;
  106. SPIComponent m_spComponent;
  107. BOOL m_bIsScopePane; // is this sheet for a scope pane node
  108. DWORD m_nCreatedCount; // count of pages actually created
  109. SPITFSNode m_spNode; // node the pages (or wizard) refers to
  110. SPITFSNode m_spParentNode; // node the pages (or wizard) refers to
  111. HWND m_hSheetWindow; // window handle to the sheet
  112. // property sheet only
  113. LONG_PTR m_hConsoleHandle; // handle for notifications to console
  114. HANDLE m_hEventHandle; // syncronization handle for property notifications
  115. // wizard only
  116. SPIPropertySheetCallback m_spSheetCallback;// cached pointer to add/remove pages
  117. int m_cDirty;
  118. BOOL m_fSetDefaultSheetPos;
  119. private:
  120. // property sheet only
  121. // variables to use across thread boundaries
  122. DWORD m_dwLastErr; // generic error code
  123. CPropertyPageBase* m_pPropChangePage; // page for which notification is valid
  124. public:
  125. HANDLE m_hThread;
  126. void SetError(DWORD dwErr) { m_dwLastErr = dwErr;}
  127. DWORD GetError() { return m_dwLastErr; }
  128. CPropertyPageBase* GetPropChangePage()
  129. { ASSERT(m_pPropChangePage != NULL); return m_pPropChangePage; }
  130. };
  131. /////////////////////////////////////////////////////////////////////////////
  132. // CPropertyPageBase
  133. class CPropertyPageBase : public CPropertyPage
  134. {
  135. DECLARE_DYNCREATE(CPropertyPageBase)
  136. // Construction
  137. private:
  138. CPropertyPageBase(){} // cannot use this constructor
  139. public:
  140. CPropertyPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
  141. virtual ~CPropertyPageBase();
  142. // Overrides
  143. public:
  144. virtual BOOL OnApply();
  145. virtual void CancelApply();
  146. protected:
  147. // Generated message map functions
  148. //{{AFX_MSG(CGeneralPage)
  149. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  150. afx_msg void OnDestroy();
  151. //}}AFX_MSG
  152. // help messages
  153. afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
  154. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  155. DECLARE_MESSAGE_MAP()
  156. // attributes
  157. public:
  158. void SetHolder(CPropertyPageHolderBase* pPageHolder);
  159. CPropertyPageHolderBase* GetHolder();
  160. PROPSHEETPAGE m_psp97;
  161. HPROPSHEETPAGE m_hPage;
  162. // property seet only
  163. virtual BOOL OnPropertyChange(BOOL bScopePane, LONG_PTR* pChangeMask) // execute from main thread
  164. { return FALSE; /* do not repaint UI */ }
  165. // Use this call to get the actual help map
  166. // this version will check the global help map first.
  167. DWORD * GetHelpMapInternal();
  168. // override this to return the pointer to the help map
  169. virtual LPDWORD GetHelpMap() { return NULL; }
  170. void InitWiz97(BOOL bHideHeader, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle);
  171. protected:
  172. // These functions set the dirty flag on the current page
  173. virtual void SetDirty(BOOL bDirty);
  174. virtual BOOL IsDirty() { return m_bIsDirty; }
  175. private:
  176. CString m_szHeaderTitle;
  177. CString m_szHeaderSubTitle;
  178. CPropertyPageHolderBase* m_pPageHolder; // backpointer to holder
  179. BOOL m_bIsDirty; // dirty flag
  180. };
  181. /*---------------------------------------------------------------------------
  182. Inlined functions
  183. ---------------------------------------------------------------------------*/
  184. inline void CPropertyPageHolderBase::AddRef()
  185. {
  186. m_nCreatedCount++;
  187. }
  188. inline DWORD CPropertyPageHolderBase::GetRefCount()
  189. {
  190. return m_nCreatedCount;
  191. }
  192. inline HWND CPropertyPageHolderBase::GetSheetWindow()
  193. {
  194. return m_hSheetWindow;
  195. }
  196. inline ITFSNode * CPropertyPageHolderBase::GetNode()
  197. {
  198. if (m_spNode)
  199. m_spNode->AddRef();
  200. return m_spNode;
  201. }
  202. inline void CPropertyPageHolderBase::SetNode(ITFSNode *pNode)
  203. {
  204. m_spNode.Set(pNode);
  205. m_spParentNode.Release();
  206. if (m_spNode)
  207. m_spNode->GetParent(&m_spParentNode);
  208. }
  209. inline ITFSNode * CPropertyPageHolderBase::GetContainer()
  210. {
  211. if (m_spParentNode)
  212. m_spParentNode->AddRef();
  213. return m_spParentNode;
  214. }
  215. inline BOOL CPropertyPageHolderBase::IsWizardMode()
  216. {
  217. return m_bWizardMode;
  218. }
  219. inline BOOL CPropertyPageHolderBase::SetWizardButtonsFirst(BOOL bValid)
  220. {
  221. return SetWizardButtons(bValid ? PSWIZB_NEXT : 0);
  222. }
  223. inline BOOL CPropertyPageHolderBase::SetWizardButtonsMiddle(BOOL bValid)
  224. {
  225. return SetWizardButtons(bValid ? (PSWIZB_BACK|PSWIZB_NEXT) : PSWIZB_BACK);
  226. }
  227. inline BOOL CPropertyPageHolderBase::SetWizardButtonsLast(BOOL bValid)
  228. {
  229. return SetWizardButtons(bValid ? (PSWIZB_BACK|PSWIZB_FINISH) : (PSWIZB_BACK|PSWIZB_DISABLEDFINISH));
  230. }
  231. inline void CPropertyPageBase::SetHolder(CPropertyPageHolderBase *pPageHolder)
  232. {
  233. Assert((pPageHolder != NULL) && (m_pPageHolder == NULL));
  234. m_pPageHolder = pPageHolder;
  235. }
  236. inline CPropertyPageHolderBase * CPropertyPageBase::GetHolder()
  237. {
  238. return m_pPageHolder;
  239. }
  240. inline void CPropertyPageBase::SetDirty(BOOL bDirty)
  241. {
  242. SetModified(bDirty);
  243. m_bIsDirty = bDirty;
  244. }
  245. // Use this function for property pages on the Scope pane
  246. HRESULT DoPropertiesOurselvesSinceMMCSucks(ITFSNode *pNode,
  247. IComponentData *pComponentData,
  248. LPCTSTR pszSheetTitle);
  249. // Use this function for property pages on the result pane
  250. HRESULT DoPropertiesOurselvesSinceMMCSucks(ITFSNode * pNode,
  251. IComponent * pComponent,
  252. LPCTSTR pszSheetTitle,
  253. int nVirtualIndex = -1);
  254. /*!--------------------------------------------------------------------------
  255. EnableChildControls
  256. Use this function to enable/disable/hide/show all child controls
  257. on a page (actually it will work with any child windows, the
  258. parent does not have to be a property page).
  259. Author: KennT
  260. ---------------------------------------------------------------------------*/
  261. HRESULT EnableChildControls(HWND hWnd, DWORD dwFlags);
  262. #define PROPPAGE_CHILD_SHOW 0x00000001
  263. #define PROPPAGE_CHILD_HIDE 0x00000002
  264. #define PROPPAGE_CHILD_ENABLE 0x00000004
  265. #define PROPPAGE_CHILD_DISABLE 0x00000008
  266. /*!--------------------------------------------------------------------------
  267. MultiEnableWindow
  268. This function takes a variable length list of control ids,
  269. that will be enabled/disabled. The last item in the control
  270. id list must be 0.
  271. The reason why I called this MultiEnableWindow instead of
  272. EnableMultiWindow is that we can grep for EnableWindow and
  273. still show these calls.
  274. Author: KennT
  275. ---------------------------------------------------------------------------*/
  276. HRESULT MultiEnableWindow(HWND hWndParent, BOOL fEnable, UINT nCtrlId, ...);
  277. #endif // _PROPPAGE_H