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.

418 lines
9.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1998 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AtlBasePage.h
  7. //
  8. // Description:
  9. // Definition of the CBasePageWindow and CBasePageImpl classes.
  10. //
  11. // Author:
  12. // David Potter (davidp) December 2, 1997
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #ifndef __ATLBASEPAGE_H_
  20. #define __ATLBASEPAGE_H_
  21. /////////////////////////////////////////////////////////////////////////////
  22. // Forward Class Declarations
  23. /////////////////////////////////////////////////////////////////////////////
  24. class CBasePageWindow;
  25. template < class T, class TBase > class CBasePageImpl;
  26. /////////////////////////////////////////////////////////////////////////////
  27. // External Class Declarations
  28. /////////////////////////////////////////////////////////////////////////////
  29. class CBaseSheetWindow;
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Include Files
  32. /////////////////////////////////////////////////////////////////////////////
  33. #ifndef __ATLDBGWIN_H_
  34. #include "AtlDbgWin.h" // for DBG_xxx routines
  35. #endif
  36. #ifndef __DLGITEMUTILS_H_
  37. #include "DlgItemUtils.h" // for CDlgItemUtils
  38. #endif
  39. #ifndef __ATLBASESHEET_H_
  40. #include "AtlBaseSheet.h" // for CBaseSheetWindow for BReadOnly()
  41. #endif
  42. #ifndef __ATLPOPUPHELP_H_
  43. #include "AtlPopupHelp.h" // for COnlineHelp
  44. #endif
  45. /////////////////////////////////////////////////////////////////////////////
  46. // Type Definitions
  47. /////////////////////////////////////////////////////////////////////////////
  48. /////////////////////////////////////////////////////////////////////////////
  49. //++
  50. //
  51. // class CBasePageWindow
  52. //
  53. // Description:
  54. // Base property sheet page window for all kinds of property sheets.
  55. //
  56. // Inheritance:
  57. // CBasePageWindow
  58. // CPropertyPageWindow, CDlgItemUtils
  59. //
  60. //--
  61. /////////////////////////////////////////////////////////////////////////////
  62. class CBasePageWindow
  63. : public CPropertyPageWindow
  64. , public CDlgItemUtils
  65. {
  66. typedef CPropertyPageWindow baseClass;
  67. public:
  68. //
  69. // Construction
  70. //
  71. // Standard constructor
  72. CBasePageWindow( HWND hWnd = NULL )
  73. : baseClass( hWnd )
  74. , m_bReadOnly( FALSE )
  75. , m_psht( NULL )
  76. , m_ppsp( NULL )
  77. {
  78. } //*** CBasePageWindow()
  79. // Destructor
  80. virtual ~CBasePageWindow( void )
  81. {
  82. //
  83. // This must be virtual so that a pointer to an object
  84. // of type CBasePropertyPageWindow can be held and then later
  85. // deleted. That way the derived class's destructor will
  86. // be called.
  87. //
  88. } //*** ~CBasePageWindow()
  89. // Initialize the page
  90. virtual BOOL BInit( IN CBaseSheetWindow * psht )
  91. {
  92. ATLASSERT( psht != NULL );
  93. ATLASSERT( m_psht == NULL );
  94. m_psht = psht;
  95. return TRUE;
  96. } //*** BInit()
  97. protected:
  98. //
  99. // CBasePageWindow helper methods.
  100. //
  101. // Attach a control to a dialog item.
  102. void AttachControl( CWindow & rwndControl, UINT idc )
  103. {
  104. HWND hwndControl = GetDlgItem( idc );
  105. ATLASSERT( hwndControl != NULL );
  106. rwndControl.Attach( hwndControl );
  107. } //*** AttachControl()
  108. public:
  109. //
  110. // CBasePageWindow public methods to override.
  111. //
  112. // Update data on or from the page
  113. virtual BOOL UpdateData( IN BOOL bSaveAndValidate )
  114. {
  115. return TRUE;
  116. } //*** UpdateData()
  117. // Apply changes made on this page to the sheet
  118. virtual BOOL BApplyChanges( void )
  119. {
  120. return TRUE;
  121. } //*** BApplyChanges()
  122. public:
  123. //
  124. // Message handler functions.
  125. //
  126. // Handler for WM_INITDIALOG
  127. BOOL OnInitDialog( void )
  128. {
  129. return TRUE;
  130. } //*** OnInitDialog()
  131. // Handler for PSN_SETACTIVE
  132. BOOL OnSetActive( void )
  133. {
  134. return UpdateData( FALSE /*bSaveAndValidate*/ );
  135. } //*** OnSetActive()
  136. // Handler for PSN_APPLY
  137. BOOL OnApply( void )
  138. {
  139. // Update the data in the class from the page.
  140. if ( ! UpdateData( TRUE /*bSaveAndValidate*/ ) )
  141. {
  142. return FALSE;
  143. } // if: error updating data
  144. // Save the data in the sheet.
  145. if ( ! BApplyChanges() )
  146. {
  147. return FALSE;
  148. } // if: error applying changes
  149. return TRUE;
  150. } //*** OnApply()
  151. // Handler for PSN_WIZBACK
  152. int OnWizardBack( void )
  153. {
  154. // 0 = goto next page
  155. // -1 = prevent page change
  156. // >0 = jump to page by dlg ID
  157. return 0;
  158. } //*** OnWizardBack()
  159. // Handler for PSN_WIZNEXT
  160. int OnWizardNext( void )
  161. {
  162. // 0 = goto next page
  163. // -1 = prevent page change
  164. // >0 = jump to page by dlg ID
  165. return 0;
  166. } //*** OnWizardNext()
  167. // Handler for PSN_WIZFINISH
  168. BOOL OnWizardFinish( void )
  169. {
  170. return TRUE;
  171. } //*** OnWizardFinish()
  172. // Handler for PSN_RESET
  173. void OnReset( void )
  174. {
  175. } //*** OnReset()
  176. // Implementation
  177. protected:
  178. PROPSHEETPAGE * m_ppsp; // Pointer to property sheet header in impl class.
  179. CBaseSheetWindow * m_psht; // Pointer to sheet this page belongs to.
  180. BOOL m_bReadOnly; // Set if the page cannot be changed.
  181. CString m_strTitle; // Used to support resource IDs for the title.
  182. CBaseSheetWindow * Psht( void ) const { return m_psht; }
  183. BOOL BReadOnly( void ) const { return m_bReadOnly || Psht()->BReadOnly(); }
  184. const CString & StrTitle( void ) const { return m_strTitle; }
  185. public:
  186. // Return a pointer to the property page header
  187. PROPSHEETPAGE * Ppsp( void ) const
  188. {
  189. ATLASSERT( m_ppsp != NULL );
  190. return m_ppsp;
  191. } //*** Ppsp()
  192. }; //*** class CBasePageWindow
  193. /////////////////////////////////////////////////////////////////////////////
  194. //++
  195. //
  196. // class CBasePageImpl
  197. //
  198. // Purpose:
  199. // Base property sheet page implementation for all kinds of property
  200. // sheets.
  201. //
  202. // Inheritance:
  203. // CBasePageImpl< T, TBase >
  204. // CPropertyPageImpl< T, TBase >, CPopupHelp< T >
  205. // <TBase>
  206. // ...
  207. // CBasePageWindow
  208. // CPropertyPageWindow
  209. //
  210. //--
  211. /////////////////////////////////////////////////////////////////////////////
  212. template < class T, class TBase = CBasePageWindow >
  213. class CBasePageImpl
  214. : public CPropertyPageImpl< T, TBase >
  215. , public CPopupHelp< T >
  216. {
  217. typedef CBasePageImpl< T, TBase > thisClass;
  218. typedef CPropertyPageImpl< T, TBase > baseClass;
  219. public:
  220. //
  221. // Construction
  222. //
  223. // Standard constructor
  224. CBasePageImpl(
  225. LPCTSTR lpszTitle = NULL
  226. )
  227. : baseClass( lpszTitle )
  228. {
  229. } //*** CBasePageImpl()
  230. public:
  231. //
  232. // Message map.
  233. //
  234. BEGIN_MSG_MAP( thisClass )
  235. #if DBG
  236. #ifdef _DBG_MSG
  237. MESSAGE_RANGE_HANDLER( 0, 0xffffffff, OnMsg )
  238. #endif // _DBG_MSG
  239. #ifdef _DBG_MSG_NOTIFY
  240. MESSAGE_HANDLER( WM_NOTIFY, OnNotify )
  241. #endif // _DBG_MSG_NOTIFY
  242. #ifdef _DBG_MSG_COMMAND
  243. MESSAGE_HANDLER( WM_COMMAND, OnCommand )
  244. #endif // _DBG_MSG_COMMAND
  245. #endif // DBG
  246. MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
  247. CHAIN_MSG_MAP( CPopupHelp< T > )
  248. CHAIN_MSG_MAP( baseClass )
  249. END_MSG_MAP()
  250. #if DBG && defined( _DBG_MSG )
  251. // Handler for any message
  252. LRESULT OnMsg( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  253. {
  254. return DBG_OnMsg( uMsg, wParam, lParam, bHandled, T::s_pszClassName );
  255. } //*** OnMsg()
  256. #endif // DBG && defined( _DBG_MSG )
  257. #if DBG && defined( _DBG_MSG_NOTIFY )
  258. // Handler for the WM_NOTIFY message
  259. LRESULT OnNotify( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  260. {
  261. return DBG_OnNotify( uMsg, wParam, lParam, bHandled, T::s_pszClassName, T::s_rgmapCtrlNames );
  262. } //*** OnNotify()
  263. #endif // DBG && defined( _DBG_MSG_NOTIFY )
  264. #if DBG && defined( _DBG_MSG_COMMAND )
  265. // Handler for the WM_COMMAND message
  266. LRESULT OnCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled )
  267. {
  268. return DBG_OnCommand( uMsg, wParam, lParam, bHandled, T::s_pszClassName, T::s_rgmapCtrlNames );
  269. } //*** OnCommand()
  270. #endif // DBG && defined( _DBG_MSG_COMMAND )
  271. //
  272. // Message handler functions.
  273. //
  274. // Handler for WM_INITDIALOG
  275. LRESULT OnInitDialog(
  276. UINT uMsg,
  277. WPARAM wParam,
  278. LPARAM lParam,
  279. BOOL & bHandled
  280. )
  281. {
  282. T * pT = static_cast< T * >( this );
  283. return pT->OnInitDialog();
  284. } //*** OnInitDialog()
  285. // Handler for WM_INITDIALOG
  286. BOOL OnInitDialog( void )
  287. {
  288. return baseClass::OnInitDialog();
  289. } //*** OnInitDialog()
  290. //
  291. // These notification handlers are needed because CPropertyPageImpl
  292. // implements them itself, which prevents the call from making it
  293. // to the window class.
  294. //
  295. // Handler for PSN_SETACTIVE
  296. BOOL OnSetActive( void )
  297. {
  298. // Call the TBase method to avoid the CPropertySheetImpl empty method
  299. return TBase::OnSetActive();
  300. } //*** OnSetActive()
  301. // Handler for PSN_APPLY
  302. BOOL OnApply( void )
  303. {
  304. // Call the TBase method to avoid the CPropertySheetImpl empty method
  305. return TBase::OnApply();
  306. } //*** OnApply()
  307. // Handler for PSN_WIZBACK
  308. int OnWizardBack( void )
  309. {
  310. // Call the TBase method to avoid the CPropertySheetImpl empty method
  311. return TBase::OnWizardBack();
  312. } //*** OnWizardBack()
  313. // Handler for PSN_WIZNEXT
  314. int OnWizardNext( void )
  315. {
  316. // Call the TBase method to avoid the CPropertySheetImpl empty method
  317. return TBase::OnWizardNext();
  318. } //*** OnWizardNext()
  319. // Handler for PSN_WIZFINISH
  320. BOOL OnWizardFinish( void )
  321. {
  322. // Call the TBase method to avoid the CPropertySheetImpl empty method
  323. return TBase::OnWizardFinish();
  324. } //*** OnWizardFinish()
  325. // Handler for PSN_RESET
  326. void OnReset( void )
  327. {
  328. // Call the TBase method to avoid the CPropertySheetImpl empty method
  329. TBase::OnReset();
  330. } //*** OnReset()
  331. // Implementation
  332. protected:
  333. public:
  334. }; //*** class CBasePageImpl
  335. /////////////////////////////////////////////////////////////////////////////
  336. #endif // __ATLBASEPAGE_H_