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.

325 lines
7.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AtlBaseSheet.h
  7. //
  8. // Implementation File:
  9. // AtlBaseSheet.cpp
  10. //
  11. // Description:
  12. // Definition of the CBaseSheetWindow and CBaseSheetImpl classes.
  13. //
  14. // Author:
  15. // David Potter (davidp) December 1, 1997
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef __ATLBASESHEET_H_
  23. #define __ATLBASESHEET_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Forward Class Declarations
  26. /////////////////////////////////////////////////////////////////////////////
  27. class CBaseSheetWindow;
  28. template < class T, class TBase > class CBaseSheetImpl;
  29. /////////////////////////////////////////////////////////////////////////////
  30. // External Class Declarations
  31. /////////////////////////////////////////////////////////////////////////////
  32. class CCluAdmExtensions;
  33. class CBasePageWindow;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Include Files
  36. /////////////////////////////////////////////////////////////////////////////
  37. #ifndef __ATLDBGWIN_H_
  38. #include "AtlDbgWin.h" // for DBG_xxx routines
  39. #endif
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Type Definitions
  42. /////////////////////////////////////////////////////////////////////////////
  43. /////////////////////////////////////////////////////////////////////////////
  44. //++
  45. //
  46. // class CBaseSheetWindow
  47. //
  48. // Description:
  49. // Base property sheet window for all kinds of property sheets.
  50. //
  51. // Inheritance:
  52. // CBaseSheetWindow
  53. // CPropertySheetWindow
  54. //
  55. //--
  56. /////////////////////////////////////////////////////////////////////////////
  57. class CBaseSheetWindow : public CPropertySheetWindow
  58. {
  59. typedef CPropertySheetWindow baseClass;
  60. public:
  61. //
  62. // Construction.
  63. //
  64. // Standard constructor
  65. CBaseSheetWindow( HWND hWnd = NULL )
  66. : baseClass( hWnd )
  67. , m_bReadOnly( FALSE )
  68. , m_bNeedToLoadExtensions( TRUE )
  69. , m_ppsh( NULL )
  70. , m_pext( NULL )
  71. {
  72. } //*** CBaseSheetWindow()
  73. // Destructor
  74. virtual ~CBaseSheetWindow( void );
  75. //
  76. // This must be virtual so that a pointer to an object
  77. // of type CBaseSheetWindow can be held and then later
  78. // deleted. That way the derived class's destructor will
  79. // be called.
  80. //
  81. // Initialize the sheet
  82. BOOL BInit( void )
  83. {
  84. return TRUE;
  85. }
  86. public:
  87. //
  88. // CPropertySheetWindow methods.
  89. //
  90. // Add a page (allows other AddPage method to be virtual)
  91. void AddPage( HPROPSHEETPAGE hPage )
  92. {
  93. baseClass::AddPage( hPage );
  94. } //*** AddPage( hPage )
  95. // Add a page (virtual so this class can call derived class method)
  96. virtual BOOL AddPage( LPCPROPSHEETPAGE pPage )
  97. {
  98. return baseClass::AddPage( pPage );
  99. } //*** AddPage( pPage )
  100. // Add a page to the propsheetheader page list
  101. virtual BAddPageToSheetHeader( IN HPROPSHEETPAGE hPage ) = 0;
  102. public:
  103. //
  104. // CBaseSheetWindow public methods.
  105. //
  106. // Create a font for use on the sheet
  107. static BOOL BCreateFont(
  108. OUT CFont & rfont,
  109. IN LONG nPoints,
  110. IN LPCTSTR pszFaceName = _T("MS Shell Dlg"),
  111. IN BOOL bBold = FALSE,
  112. IN BOOL bItalic = FALSE,
  113. IN BOOL bUnderline = FALSE
  114. );
  115. // Create a font for use on the sheet
  116. static BOOL BCreateFont(
  117. OUT CFont & rfont,
  118. IN UINT idsPoints,
  119. IN UINT idsFaceName,
  120. IN BOOL bBold = FALSE,
  121. IN BOOL bItalic = FALSE,
  122. IN BOOL bUnderline = FALSE
  123. );
  124. public:
  125. //
  126. // Abstract override methods.
  127. //
  128. // Add extension pages to the sheet
  129. virtual void AddExtensionPages( IN HFONT hfont, IN HICON hicon ) = 0;
  130. // Add a page (called by extension)
  131. virtual HRESULT HrAddExtensionPage( IN CBasePageWindow * ppage ) = 0;
  132. public:
  133. //
  134. // Message handler functions.
  135. //
  136. // Handler for PSCB_INITIALIZED
  137. void OnSheetInitialized( void )
  138. {
  139. } //*** OnSheetInitialized()
  140. // Implementation
  141. protected:
  142. PROPSHEETHEADER * m_ppsh;
  143. BOOL m_bReadOnly; // Set if the sheet cannot be changed.
  144. BOOL m_bNeedToLoadExtensions;
  145. CCluAdmExtensions * m_pext;
  146. public:
  147. BOOL BNeedToLoadExtensions( void ) const { return m_bNeedToLoadExtensions; }
  148. BOOL BReadOnly( void ) const { return m_bReadOnly; }
  149. void SetReadOnly( IN BOOL bReadOnly = TRUE ) { m_bReadOnly = bReadOnly; }
  150. // Return a pointer to the property sheet header
  151. PROPSHEETHEADER * Ppsh( void ) const
  152. {
  153. ATLASSERT( m_ppsh != NULL );
  154. return m_ppsh;
  155. } //*** Ppsh()
  156. CCluAdmExtensions * Pext( void ) const { return m_pext; }
  157. }; //*** class CBaseSheetWindow
  158. /////////////////////////////////////////////////////////////////////////////
  159. //++
  160. //
  161. // class CBaseSheetImpl
  162. //
  163. // Description:
  164. // Base property sheet implementation for all kinds of property sheets.
  165. //
  166. // Inheritance
  167. // CBaseSheetImpl< T, TBase >
  168. // CPropertySheetImpl< T, TBase >
  169. // <TBase>
  170. // ...
  171. // CBaseSheetWindow
  172. // CPropertySheetWindow
  173. //
  174. //--
  175. /////////////////////////////////////////////////////////////////////////////
  176. template < class T, class TBase = CBaseSheetWindow >
  177. class CBaseSheetImpl : public CPropertySheetImpl< T, TBase >
  178. {
  179. typedef CBaseSheetImpl< T, TBase > thisClass;
  180. typedef CPropertySheetImpl< T, TBase > baseClass;
  181. public:
  182. //
  183. // Construction.
  184. //
  185. // Standard constructor
  186. CBaseSheetImpl(
  187. IN LPCTSTR lpszTitle = NULL,
  188. IN UINT uStartPage = 0,
  189. IN HWND hWndParent = NULL
  190. )
  191. : baseClass( lpszTitle, uStartPage, hWndParent )
  192. {
  193. } //*** CBaseSheetImpl()
  194. static int CALLBACK PropSheetCallback( HWND hWnd, UINT uMsg, LPARAM lParam )
  195. {
  196. //
  197. // If we are initialized, let the sheet do further initialization.
  198. // We have to subclass here because otherwize we won't have a
  199. // pointer to the class instance.
  200. //
  201. if ( uMsg == PSCB_INITIALIZED )
  202. {
  203. ATLASSERT( hWnd != NULL );
  204. T * pT = static_cast< T * >( _Module.ExtractCreateWndData() );
  205. ATLASSERT( pT != NULL );
  206. pT->SubclassWindow(hWnd);
  207. pT->OnSheetInitialized();
  208. } // if: sheet has been initialized
  209. return 0;
  210. } //*** PropSheetCallback()
  211. public:
  212. //
  213. // CPropertySheetImpl methods.
  214. //
  215. // Add a page to the propsheetheader page list
  216. virtual BAddPageToSheetHeader( IN HPROPSHEETPAGE hPage )
  217. {
  218. return AddPage( hPage );
  219. } //*** BAddPageToHeader()
  220. public:
  221. //
  222. // Message map.
  223. //
  224. BEGIN_MSG_MAP( thisClass )
  225. #if DBG
  226. #ifdef _DBG_MSG
  227. MESSAGE_RANGE_HANDLER( 0, 0xffffffff, OnMsg )
  228. #endif // _DBG_MSG
  229. #ifdef _DBG_MSG_NOTIFY
  230. MESSAGE_HANDLER( WM_NOTIFY, OnNotify )
  231. #endif // _DBG_MSG_NOTIFY
  232. #ifdef _DBG_MSG_COMMAND
  233. MESSAGE_HANDLER( WM_COMMAND, OnCommand )
  234. #endif // _DBG_MSG_COMMAND
  235. #endif // DBG
  236. // CHAIN_MSG_MAP( baseClass ) // doesn't work because base class doesn't have a message map
  237. END_MSG_MAP()
  238. public:
  239. //
  240. // Message handler functions.
  241. //
  242. #if DBG && defined( _DBG_MSG )
  243. // Handler for any message
  244. LRESULT OnMsg( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  245. {
  246. return DBG_OnMsg( uMsg, wParam, lParam, bHandled, T::s_pszClassName );
  247. } //*** OnMsg()
  248. #endif // DBG && defined( _DBG_MSG )
  249. #if DBG && defined( _DBG_MSG_NOTIFY )
  250. // Handler for the WM_NOTIFY message
  251. LRESULT OnNotify( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  252. {
  253. return DBG_OnNotify( uMsg, wParam, lParam, bHandled, T::s_pszClassName, NULL );
  254. } //*** OnNotify()
  255. #endif // DBG && defined( _DBG_MSG_NOTIFY )
  256. #if DBG && defined( _DBG_MSG_COMMAND )
  257. // Handler for the WM_COMMAND message
  258. LRESULT OnCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  259. {
  260. return DBG_OnCommand( uMsg, wParam, lParam, bHandled, T::s_pszClassName, NULL );
  261. } //*** OnCommand()
  262. #endif // DBG && defined( _DBG_MSG_COMMAND )
  263. // Implementation
  264. protected:
  265. public:
  266. }; //*** class CBaseSheetImpl
  267. /////////////////////////////////////////////////////////////////////////////
  268. #endif // __ATLBASESHEET_H_