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.

534 lines
13 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // AtlBasePropPage.cpp
  7. //
  8. // Description:
  9. // Definition of the CBasePropertyPageWindow and CBasePropertyPageImpl
  10. // classes.
  11. //
  12. // Implementation File:
  13. // None.
  14. //
  15. // Author:
  16. // David Potter (davidp) February 26, 1998
  17. //
  18. // Revision History:
  19. //
  20. // Notes:
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. #ifndef __ATLBASEPROPPAGE_H_
  24. #define __ATLBASEPROPPAGE_H_
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Forward Class Declarations
  27. /////////////////////////////////////////////////////////////////////////////
  28. class CBasePropertyPageWindow;
  29. class CStaticPropertyPageWindow;
  30. class CDynamicPropertyPageWindow;
  31. class CExtensionPropertyPageWindow;
  32. template < class T, class TWin > class CBasePropertyPageImpl;
  33. template < class T > class CStaticPropertyPageImpl;
  34. template < class T > class CDynamicPropertyPageImpl;
  35. template < class T > class CExtensionPropertyPageImpl;
  36. /////////////////////////////////////////////////////////////////////////////
  37. // External Class Declarations
  38. /////////////////////////////////////////////////////////////////////////////
  39. class CBasePropertySheetWindow;
  40. /////////////////////////////////////////////////////////////////////////////
  41. // Include Files
  42. /////////////////////////////////////////////////////////////////////////////
  43. #ifndef __ATLBASEPAGE_H_
  44. #include "AtlBasePage.h" // for CBasePageWindow, CBasePageImpl
  45. #endif
  46. #ifndef __ATLDBGWIN_H_
  47. #include "AtlDbgWin.h" // for debugging definitions
  48. #endif
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Type Definitions
  51. /////////////////////////////////////////////////////////////////////////////
  52. typedef std::list< CBasePropertyPageWindow * > CPropertyPageList;
  53. typedef std::list< CStaticPropertyPageWindow * > CStaticPropertyPageList;
  54. typedef std::list< CDynamicPropertyPageWindow * > CDynamicPropertyPageList;
  55. typedef std::list< CExtensionPropertyPageWindow * > CExtensionPropertyPageList;
  56. /////////////////////////////////////////////////////////////////////////////
  57. //++
  58. //
  59. // class CBasePropertyPageWindow
  60. //
  61. // Description:
  62. // Base property sheet page window for standard property sheets.
  63. //
  64. // Inheritance:
  65. // CBasePropertyPageWindow
  66. // CBasePageWindow
  67. // CPropertyPageWindow
  68. //
  69. //--
  70. /////////////////////////////////////////////////////////////////////////////
  71. class CBasePropertyPageWindow : public CBasePageWindow
  72. {
  73. typedef CBasePageWindow baseClass;
  74. public:
  75. //
  76. // Construction
  77. //
  78. // Standard constructor
  79. CBasePropertyPageWindow( HWND hWnd = NULL )
  80. : baseClass( hWnd )
  81. {
  82. } //*** CBasePropertyPageWindow()
  83. public:
  84. //
  85. // Message handler functions.
  86. //
  87. // Handler for PSN_KILLACTIVE
  88. BOOL OnKillActive( void )
  89. {
  90. return UpdateData( TRUE /*bSaveAndValidate*/ );
  91. } //*** OnKillActive()
  92. // Implementation
  93. protected:
  94. // Return pointer to the base sheet object
  95. CBasePropertySheetWindow * Pbsht( void ) const
  96. {
  97. return (CBasePropertySheetWindow *) Psht();
  98. } //*** Pbsht()
  99. public:
  100. }; //*** class CBasePropertyPageWindow
  101. /////////////////////////////////////////////////////////////////////////////
  102. //++
  103. //
  104. // class CStaticPropertyPageWindow
  105. //
  106. // Description:
  107. // Base property sheet page window for pages added to a standard
  108. // property sheet before the call to PropertySheet(). This page cannot
  109. // be removed from the sheet.
  110. //
  111. // Inheritance:
  112. // CStaticPropertyPageWindow
  113. // CBasePropertyPageWindow
  114. // CBasePageWindow
  115. // CPropertyPageWindow
  116. //
  117. //--
  118. /////////////////////////////////////////////////////////////////////////////
  119. class CStaticPropertyPageWindow : public CBasePropertyPageWindow
  120. {
  121. typedef CBasePropertyPageWindow baseClass;
  122. public:
  123. //
  124. // Construction
  125. //
  126. // Standard constructor
  127. CStaticPropertyPageWindow( HWND hWnd = NULL )
  128. : baseClass( hWnd )
  129. {
  130. } //*** CStaticPropertyPageWindow()
  131. }; //*** class CStaticPropertyPageWindow
  132. /////////////////////////////////////////////////////////////////////////////
  133. //++
  134. //
  135. // class CDynamicPropertyPageWindow
  136. //
  137. // Description:
  138. // Base property sheet page window for pages added to a standard
  139. // property sheet after the call to PropertySheet(). This page may be
  140. // removed from the sheet.
  141. //
  142. // Inheritance:
  143. // CDynamicPropertyPageWindow
  144. // CBasePropertyPageWindow
  145. // CBasePageWindow
  146. // CPropertyPageWindow
  147. //
  148. //--
  149. /////////////////////////////////////////////////////////////////////////////
  150. class CDynamicPropertyPageWindow : public CBasePropertyPageWindow
  151. {
  152. typedef CBasePropertyPageWindow baseClass;
  153. public:
  154. //
  155. // Construction
  156. //
  157. // Standard constructor
  158. CDynamicPropertyPageWindow( HWND hWnd = NULL )
  159. : baseClass( hWnd )
  160. , m_hpage( NULL )
  161. , m_bPageAddedToSheet( FALSE )
  162. {
  163. } //*** CDynamicPropertyPageWindow()
  164. // Destructor
  165. ~CDynamicPropertyPageWindow( void )
  166. {
  167. //
  168. // Destroy the page if it hasn't been added to the sheet yet.
  169. // If it has been added to the sheet, the sheet will destroy it.
  170. //
  171. if ( (m_hpage != NULL)
  172. && ! m_bPageAddedToSheet )
  173. {
  174. DestroyPropertySheetPage( m_hpage );
  175. m_hpage = NULL;
  176. } // if: page not deleted yet
  177. } //*** ~CDynamicPropertyPageWindow()
  178. // Create the page
  179. virtual DWORD ScCreatePage( void ) = 0;
  180. protected:
  181. HPROPSHEETPAGE m_hpage;
  182. BOOL m_bPageAddedToSheet;
  183. public:
  184. // Property page handle
  185. HPROPSHEETPAGE Hpage( void ) const { return m_hpage; }
  186. // Set whether the page has been added to the sheet or not
  187. void SetPageAdded( IN BOOL bAdded = TRUE )
  188. {
  189. m_bPageAddedToSheet = bAdded;
  190. if ( ! bAdded )
  191. {
  192. m_hpage = NULL;
  193. } // if: removing page
  194. } //*** SetPageAdded()
  195. }; //*** class CDynamicPropertyPageWindow
  196. /////////////////////////////////////////////////////////////////////////////
  197. //++
  198. //
  199. // class CExtensionWizardPageWindow
  200. //
  201. // Description:
  202. // Base property sheet page window for pages added to a standard
  203. // property sheet after the call to PropertySheet() identified as an
  204. // extension to the list of standard pages (whether static or dynamic).
  205. // This page may be removed from the sheet.
  206. //
  207. // Inheritance:
  208. // CExtensionPropertyPageWindow
  209. // CDynamicPropertyPageWindow
  210. // CBasePropertyPageWindow
  211. // CBasePageWindow
  212. // CPropertyPageWindow
  213. //
  214. //--
  215. /////////////////////////////////////////////////////////////////////////////
  216. class CExtensionPropertyPageWindow : public CDynamicPropertyPageWindow
  217. {
  218. typedef CDynamicPropertyPageWindow baseClass;
  219. public:
  220. //
  221. // Construction
  222. //
  223. // Standard constructor
  224. CExtensionPropertyPageWindow( HWND hWnd = NULL )
  225. : baseClass( hWnd )
  226. {
  227. } //*** CExtensionPropertyPageWindow()
  228. }; //*** class CExtensionPropertyPageWindow
  229. /////////////////////////////////////////////////////////////////////////////
  230. //++
  231. //
  232. // class CBasePropertyPageImpl
  233. //
  234. // Description:
  235. // Base property sheet page implementation for standard property sheets.
  236. //
  237. // Inheritance:
  238. // CBasePropertyPageImpl< T, TWin >
  239. // CBasePageImpl< T, TWin >
  240. // CPropertyPageImpl< T, TWin >
  241. // <TWin>
  242. // ...
  243. // CBasePropertyPageWindow
  244. // CBasePageWindow
  245. // CPropertyPageWindow
  246. //
  247. //--
  248. /////////////////////////////////////////////////////////////////////////////
  249. template < class T, class TWin = CBasePropertyPageWindow >
  250. class CBasePropertyPageImpl : public CBasePageImpl< T, TWin >
  251. {
  252. typedef CBasePropertyPageImpl< T, TWin > thisClass;
  253. typedef CBasePageImpl< T, TWin > baseClass;
  254. public:
  255. //
  256. // Construction
  257. //
  258. // Standard constructor
  259. CBasePropertyPageImpl(
  260. IN OUT LPCTSTR lpszTitle = NULL
  261. )
  262. : baseClass( lpszTitle )
  263. {
  264. // Set the pointer in the base window class to our prop page header.
  265. m_ppsp = &m_psp;
  266. } //*** CBasePropertyPageImpl( lpszTitle )
  267. // Constructor taking a resource ID for the title
  268. CBasePropertyPageImpl(
  269. IN UINT nIDTitle
  270. )
  271. : baseClass( nIDTitle )
  272. {
  273. // Set the pointer in the base window class to our prop page header.
  274. m_ppsp = &m_psp;
  275. } //*** CBasePropertyPageImpl( nIDCaption )
  276. // Initialize the page
  277. virtual BOOL BInit( CBaseSheetWindow * psht )
  278. {
  279. if ( ! baseClass::BInit( psht ) )
  280. return FALSE;
  281. return TRUE;
  282. } //*** BInit()
  283. public:
  284. //
  285. // Message handler functions.
  286. //
  287. // Handler for PSN_KILLACTIVE
  288. BOOL OnKillActive( void )
  289. {
  290. // Call the TWin method
  291. return TWin::OnKillActive();
  292. } //*** OnKillActive()
  293. // Implementation
  294. protected:
  295. public:
  296. }; //*** class CBasePropertyPageImpl
  297. /////////////////////////////////////////////////////////////////////////////
  298. //++
  299. //
  300. // class CStaticPropertyPageImpl
  301. //
  302. // Description:
  303. // Base property sheet page implementation for pages added to a standard
  304. // property sheet before the call to PropertySheet(). This page cannot
  305. // be removed from the sheet.
  306. //
  307. // Inheritance:
  308. // CStaticPropertyPageImpl< T >
  309. // CBasePropertyPageImpl< T, CStaticPropertyPageWindow >
  310. // CBasePageImpl< T, CStaticPropertyPageWindow >
  311. // CPropertyPageImpl< T, CStaticPropertyPageWindow >
  312. // CStaticPropertyPageWindow
  313. // CBasePropertyPageWindow
  314. // CBasePageWindow
  315. // CPropertyPageWindow
  316. //
  317. //--
  318. /////////////////////////////////////////////////////////////////////////////
  319. template < class T >
  320. class CStaticPropertyPageImpl : public CBasePropertyPageImpl< T, CStaticPropertyPageWindow >
  321. {
  322. typedef CStaticPropertyPageImpl< T > thisClass;
  323. typedef CBasePropertyPageImpl< T, CStaticPropertyPageWindow > baseClass;
  324. public:
  325. //
  326. // Construction.
  327. //
  328. // Standard constructor
  329. CStaticPropertyPageImpl(
  330. IN OUT LPCTSTR lpszTitle = NULL
  331. )
  332. : baseClass( lpszTitle )
  333. {
  334. } //*** CStaticPropertyPageImpl( lpszTitle )
  335. // Constructor taking a resource ID for the title
  336. CStaticPropertyPageImpl(
  337. IN UINT nIDTitle
  338. )
  339. : baseClass( nIDTitle )
  340. {
  341. } //*** CStaticPropertyPageImpl( nIDTitle )
  342. }; //*** class CStaticPropertyPageImpl
  343. /////////////////////////////////////////////////////////////////////////////
  344. //++
  345. //
  346. // class CDynamicPropertyPageImpl
  347. //
  348. // Description:
  349. // Base property sheet page implementation for pages added to a standard
  350. // property sheet after the call to PropertySheet() identified as an
  351. // Extension to the list of standard pages (whether static or dynamic).
  352. // This page may be removed from the sheet.
  353. //
  354. // Inheritance:
  355. // CDynamicPropertyPageImpl< T >
  356. // CBasePropertyPageImpl< T, CDynamicPropertyPageWindow >
  357. // CBasePageImpl< T, CDynamicPropertyPageWindow >
  358. // CPropertyPageImpl< T, CDynamicPropertyPageWindow >
  359. // CDynamicPropertyPageWindow
  360. // CBasePropertyPageWindow
  361. // CBasePageWindow
  362. // CPropertyPageWindow
  363. //
  364. //--
  365. /////////////////////////////////////////////////////////////////////////////
  366. template < class T >
  367. class CDynamicPropertyPageImpl : public CBasePropertyPageImpl< T, CDynamicPropertyPageWindow >
  368. {
  369. typedef CDynamicPropertyPageImpl< T > thisClass;
  370. typedef CBasePropertyPageImpl< T, CDynamicPropertyPageWindow > baseClass;
  371. public:
  372. //
  373. // Construction.
  374. //
  375. // Standard constructor
  376. CDynamicPropertyPageImpl(
  377. IN OUT LPCTSTR lpszTitle = NULL
  378. )
  379. : baseClass( lpszTitle )
  380. {
  381. } //*** CDynamicPropertyPageImpl( lpszTitle )
  382. // Constructor taking a resource ID for the title
  383. CDynamicPropertyPageImpl(
  384. IN UINT nIDTitle
  385. )
  386. : baseClass( nIDTitle )
  387. {
  388. } //*** CDynamicPropertyPageImpl( nIDTitle )
  389. // Create the page
  390. DWORD ScCreatePage( void )
  391. {
  392. ATLASSERT( m_hpage == NULL );
  393. m_hpage = CreatePropertySheetPage( &m_psp );
  394. if ( m_hpage == NULL )
  395. {
  396. return GetLastError();
  397. } // if: error creating the page
  398. return ERROR_SUCCESS;
  399. } //*** ScCreatePage()
  400. }; //*** class CDynamicPropertyPageImpl
  401. /////////////////////////////////////////////////////////////////////////////
  402. //++
  403. //
  404. // class CExtensionPropertyPageImpl
  405. //
  406. // Description:
  407. // Base property sheet page implementation for pages added to a standard
  408. // property sheet after the call to PropertySheet() identified as an
  409. // extension to the list of standard pages (whether static or dynamic).
  410. // This page may be removed from the sheet.
  411. //
  412. // Inheritance:
  413. // CExtensionPropertyPageImpl< T >
  414. // CBasePropertyPageImpl< T, CExtensionPropertyPageWindow >
  415. // CBasePageImpl< T, CExtensionPropertyPageWindow >
  416. // CPropertyPageImpl< T, CExtensionPropertyPageWindow >
  417. // CExtensionPropertyPageWindow
  418. // CDynamicPropertyPageWindow
  419. // CBasePropertyPageWindow
  420. // CBasePageWindow
  421. // CPropertyPageWindow
  422. //
  423. //--
  424. /////////////////////////////////////////////////////////////////////////////
  425. template < class T >
  426. class CExtensionPropertyPageImpl : public CBasePropertyPageImpl< T, CExtensionPropertyPageWindow >
  427. {
  428. typedef CExtensionPropertyPageImpl< T > thisClass;
  429. typedef CBasePropertyPageImpl< T, CExtensionPropertyPageWindow > baseClass;
  430. public:
  431. //
  432. // Construction.
  433. //
  434. // Standard constructor
  435. CExtensionPropertyPageImpl(
  436. IN OUT LPCTSTR lpszTitle = NULL
  437. )
  438. : baseClass( lpszTitle )
  439. {
  440. } //*** CExtensionPropertyPageImpl( lpszTitle )
  441. // Constructor taking a resource ID for the title
  442. CExtensionPropertyPageImpl(
  443. IN UINT nIDTitle
  444. )
  445. : baseClass( nIDTitle )
  446. {
  447. } //*** CExtensionPropertyPageImpl( nIDTitle )
  448. }; //*** class CExtensionPropertyPageImpl
  449. /////////////////////////////////////////////////////////////////////////////
  450. #endif // __ATLBASEPROPPAGE_H_