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.

129 lines
5.2 KiB

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // CPropertySHeetHeader is a wrapper class around the PROPSHEETHEADER structure
  3. // this class mostly does data validation. The operator[] and Iterator member class allows for
  4. // pretty syntax. Hopefully the prettyness outweighs the confusion...
  5. //
  6. //
  7. // CPropertySheetHeader MyPropSheetHeader( 2, // NumPropShtPages
  8. // PSH_PROPSHEETPAGE | PSH_WIZARD // Flags
  9. // );
  10. //
  11. //
  12. //
  13. // CPropertySheetPage MyPropertySheetPage(
  14. // IDD_PROPPAGE_TEMPLATE,
  15. // ( DLGPROC ) MyDlgProc,
  16. // PSP_HASHELP
  17. // );
  18. // extern PROPSHEETPAGE OtherPage;
  19. //
  20. // MyPropSheetHeader[ 0 ] = MyPropertySheetPage;
  21. // MyPropSheetHeader[ 1 ] = OtherPage;
  22. //
  23. //
  24. ////////////////////////////////////////////////////////////////////////////////////////////////////
  25. #ifndef __PhtHdr_h__
  26. #define __PhtHdr_h__
  27. ////////////////////////////////////////////////////////////////////////////////////////////////////
  28. // Include files
  29. #include "PropPg.h"
  30. ////////////////////////////////////////////////////////////////////////////////////////////////////
  31. // Comment this if you do not want parameter validation ( class would do essentially nothing )
  32. //
  33. #define CPropertySheetHeader_ValidateParameters
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////
  35. ////////////////////////////////////////////////////////////////////////////////////////////////////
  36. // Property Sheet Header
  37. class CPropertySheetHeader : public PROPSHEETHEADER {
  38. // Forward declarations and friend declarations
  39. class CPropertySheetPageDataIterator;
  40. friend CPropertySheetPageDataIterator;
  41. private: // DATATYPES
  42. ///////////////////////////////////////////////////////////////////////////////////////////
  43. // CPropertySheetPageDataIterator is for getting at a PROPSHEETPAGE in the ppsp member
  44. // array of a PROPSHEETHEADER
  45. class CPropertySheetPageDataIterator {
  46. // Forward Decls and Friend decls
  47. friend CPropertySheetHeader;
  48. private: // DATA
  49. UINT m_Index;
  50. PROPSHEETHEADER *m_pPsh;
  51. private: // Construction / destruction
  52. // This may only be created by CPropertySheetHeader
  53. CPropertySheetPageDataIterator( UINT index, PROPSHEETHEADER* pPsh )
  54. : m_Index( index ), m_pPsh( pPsh ) { ; }
  55. public:
  56. ~CPropertySheetPageDataIterator( void ) { ; }
  57. public: // Public Member Fns
  58. void operator=( LPCPROPSHEETPAGE p ) {
  59. assert( m_pPsh -> dwFlags & PSH_PROPSHEETPAGE ); // We only handle this case now
  60. const_cast< LPPROPSHEETPAGE >( m_pPsh -> ppsp )[ m_Index ] = *p;
  61. }
  62. void operator=( HPROPSHEETPAGE FAR * p ) {
  63. assert( !( m_pPsh -> dwFlags & PSH_PROPSHEETPAGE ) ); // We only handle this case now
  64. m_pPsh -> phpage[ m_Index ] = *p;
  65. }
  66. private: // UNUSED
  67. CPropertySheetPageDataIterator( void );
  68. CPropertySheetPageDataIterator( const CPropertySheetPageDataIterator& r );
  69. };
  70. public: // symbol classes for signature disambiguation...
  71. class UsePropertySheetArray{ ; };
  72. class UsePropertySheetHandleArray{ ; };
  73. public: // Construction / destruction
  74. CPropertySheetHeader( void );
  75. CPropertySheetHeader( LPCPROPSHEETPAGE pPageVector, int nPages, PFNPROPSHEETCALLBACK pfnCallback = NULL );
  76. CPropertySheetHeader( int nPages, UsePropertySheetArray dummy, PFNPROPSHEETCALLBACK pfnCallback = NULL );
  77. CPropertySheetHeader( int nPages, DWORD dwFlags, PFNPROPSHEETCALLBACK pfnCallback = NULL );
  78. CPropertySheetHeader( int nPages, UsePropertySheetHandleArray dummy, PFNPROPSHEETCALLBACK pfnCallback = NULL );
  79. ~CPropertySheetHeader( void );
  80. // Methods and operators
  81. CPropertySheetPageDataIterator operator[]( int index );
  82. void SetParent( HWND hWndParent ) { _Set_hwndParent( hWndParent ); }
  83. // Conversion operator
  84. operator LPPROPSHEETHEADER() { return this; }
  85. private: // Helper Fns
  86. BOOL _InitData( void );
  87. BOOL _Validate( void );
  88. BOOL _Set_hwndParent( HWND hwndParent );
  89. BOOL _Set_hInstance( HINSTANCE hInstance );
  90. BOOL _Set_hIcon( HICON hIcon );
  91. BOOL _Set_pszIcon( LPCTSTR pszIcon );
  92. BOOL _Set_pszCaption( LPCTSTR pszCaption );
  93. BOOL _Set_nStartPage( UINT nStartPage );
  94. BOOL _Set_pStartPage( LPCTSTR pStartPage );
  95. BOOL _Set_ppsp( LPCPROPSHEETPAGE ppsp, UINT nPages );
  96. BOOL _Set_phpage( HPROPSHEETPAGE FAR phpage, UINT nPages );
  97. BOOL _Set_pfnCallback( PFNPROPSHEETCALLBACK pfnCallback );
  98. BOOL _DeletePageData( void );
  99. private: // UNUSED
  100. CPropertySheetHeader( const CPropertySheetHeader& r );
  101. CPropertySheetHeader& operator=( const CPropertySheetHeader& r );
  102. };
  103. #endif // __PhtHdr_h__