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.

211 lines
6.5 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1997 - 1999
  3. //
  4. // File: rtrsheet.h
  5. //
  6. // History:
  7. // 08/04/97 Kenn M. Takara Created.
  8. //
  9. // Router property sheet common code.
  10. //============================================================================
  11. #ifndef _RTRSHEET_H_
  12. #define _RTRSHEET_H_
  13. //----------------------------------------------------------------------------
  14. // Class: RtrPropertySheet
  15. //
  16. // This class is used by property sheets in the router administration tool.
  17. // It is intended to host pages derived from RtrPropertyPage (below).
  18. //
  19. // This is derived from CPropertyPageHolderBase. Sheets derived
  20. // from this class allow their creators to specify a callback
  21. // to be invoked when certain events occur, such as closing the sheet or
  22. // applying changes.
  23. //
  24. // It also allows its contained pages to accumulate their changes in memory
  25. // when the user selects "Apply"; the changes are then saved together,
  26. // rather than having each page save its own changes.
  27. // Note that this increases the performance of the router UI, which uses RPC
  28. // to save its information; using this class results in a single RPC call
  29. // to save changes, rather than separate calls from each of the pages.
  30. //----------------------------------------------------------------------------
  31. class RtrPropertySheet : public CPropertyPageHolderBase
  32. {
  33. public:
  34. //-------------------------------------------------------------------
  35. // Constructors
  36. //
  37. //-------------------------------------------------------------------
  38. RtrPropertySheet( ITFSNode * pNode,
  39. IComponentData *pComponentData,
  40. ITFSComponentData *pTFSCompData,
  41. LPCTSTR pszSheetName,
  42. CWnd* pParent = NULL,
  43. UINT iPage = 0,
  44. BOOL fScopePane = FALSE);
  45. // --------------------------------------------------------
  46. // Function: PressButton
  47. //
  48. // This function is identical to the CPropertySheet::PressButton
  49. //
  50. // --------------------------------------------------------
  51. BOOL PressButton(int nButton)
  52. {
  53. Assert(::IsWindow(GetSheetWindow()));
  54. return (BOOL) ::PostMessage(GetSheetWindow(), PSM_PRESSBUTTON, nButton, 0);
  55. }
  56. // --------------------------------------------------------
  57. // Function: OnPropertyChange
  58. //
  59. // This is the code that gets executed on the main thread
  60. // by the property sheet in order to make changes to the data.
  61. //
  62. // We will call the ApplyAll() function (which is implemented
  63. // by the derived classes) and then call the base class to
  64. // then save the page itself.
  65. // --------------------------------------------------------
  66. virtual BOOL OnPropertyChange(BOOL bScopePane, LONG_PTR* pChangeMask);
  67. // --------------------------------------------------------
  68. // Function: SaveSheetData
  69. //
  70. // This function should be overridden by the user. This is
  71. // the function that gets called AFTER ApplySheetData() has
  72. // been called on all of the pages.
  73. // --------------------------------------------------------
  74. virtual BOOL SaveSheetData()
  75. {
  76. return TRUE;
  77. }
  78. virtual void CancelSheetData()
  79. {
  80. };
  81. void SetCancelFlag(BOOL fCancel)
  82. {
  83. m_fCancel = fCancel;
  84. }
  85. BOOL IsCancel()
  86. {
  87. return m_fCancel;
  88. }
  89. protected:
  90. SPITFSComponentData m_spTFSCompData;
  91. BOOL m_fCancel;
  92. };
  93. //----------------------------------------------------------------------------
  94. // Class: RtrPropertyPage
  95. //
  96. // This class is used for property-pages in the router administration tool.
  97. // It is intended to be contained by a RtrPropertySheet-derived object.
  98. //
  99. // This class supports the ability for the RtrPropertySheet to do
  100. // the actual apply (to save on RPCs we batch the Apply into one function
  101. // at the sheet level rather than the page level). The page does
  102. // this by setting the sheet to be dirty when the page itself is marked
  103. // dirty. The actual code to save the global data in the PropertySheet
  104. // is done by the RtrPropertySheet.
  105. //
  106. // When an apply is performed, the RtrPropertySheet calls "ApplySheetData"
  107. // on each of the pages. The pages will then save their data and the
  108. // property sheet will then save this global data.
  109. //----------------------------------------------------------------------------
  110. class RtrPropertyPage : public CPropertyPageBase
  111. {
  112. DECLARE_DYNAMIC(RtrPropertyPage);
  113. public:
  114. //-------------------------------------------------------------------
  115. // Constructors
  116. //
  117. //-------------------------------------------------------------------
  118. RtrPropertyPage(
  119. UINT nIDTemplate,
  120. UINT nIDCaption = 0
  121. ) : CPropertyPageBase(nIDTemplate, nIDCaption),
  122. m_hIcon(NULL)
  123. {
  124. }
  125. virtual ~RtrPropertyPage();
  126. virtual void OnCancel();
  127. //-------------------------------------------------------------------
  128. // Function: Cancel
  129. //
  130. // Called to cancel the sheet.
  131. //-------------------------------------------------------------------
  132. virtual VOID Cancel()
  133. {
  134. ((RtrPropertySheet*)GetHolder())->PressButton(PSBTN_CANCEL);
  135. }
  136. // --------------------------------------------------------
  137. // Function: SetDirty
  138. //
  139. // Override the default implementation to forward the SetDirty()
  140. // call to the property sheet so that the property sheet can
  141. // save global data.
  142. // --------------------------------------------------------
  143. virtual void SetDirty(BOOL bDirty);
  144. // ----------------------------------------------------------------
  145. // Function: ValidateSpinRange
  146. //
  147. // Checks and corrects a spin control that goes out of range.
  148. // This function will reset the spin control to its lower
  149. // value if it finds it to be out-of-range.
  150. // ----------------------------------------------------------------
  151. void ValidateSpinRange(CSpinButtonCtrl *pSpin);
  152. // ----------------------------------------------------------------
  153. // Function : OnApply
  154. //
  155. // We override this so that we can clear the dirty flag.
  156. // ----------------------------------------------------------------
  157. virtual BOOL OnApply();
  158. virtual void CancelApply();
  159. // ----------------------------------------------------------------
  160. // Function : InitializeInterfaceIcon
  161. //
  162. // Use this function to specialize the icon.
  163. // ----------------------------------------------------------------
  164. void InitializeInterfaceIcon(UINT idcIcon, DWORD dwType);
  165. protected:
  166. HICON m_hIcon;
  167. };
  168. #endif // _RTRSHEET_H_