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.

371 lines
11 KiB

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // Include Files
  3. #include "precomp.h"
  4. #include "PropPg.h"
  5. #include "PShtHdr.h"
  6. ////////////////////////////////////////////////////////////////////////////////////////////////////
  7. // Construction, destruction, and Initialization
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////
  9. //--------------------------------------------------------------------------------------------------
  10. // CPropertySheetHeader::CPropertySheetHeader
  11. CPropertySheetHeader::CPropertySheetHeader( void ) {
  12. _InitData();
  13. }
  14. //--------------------------------------------------------------------------------------------------
  15. // CPropertySheetHeader::CPropertySheetHeader
  16. CPropertySheetHeader::CPropertySheetHeader( int nPages, UsePropertySheetArray dummy, PFNPROPSHEETCALLBACK pfnCallback /* = NULL */ ) {
  17. _InitData();
  18. this -> ppsp = new PROPSHEETPAGE[ nPages ];
  19. this -> dwFlags |= PSH_PROPSHEETPAGE;
  20. this -> nPages = nPages;
  21. _Set_pfnCallback( pfnCallback );
  22. #ifdef CPropertySheetHeader_ValidateParameters
  23. #endif // CPropertySheetHeader_ValidateParameters
  24. _Validate();
  25. }
  26. //--------------------------------------------------------------------------------------------------
  27. // CPropertySheetHeader::CPropertySheetHeader
  28. CPropertySheetHeader::CPropertySheetHeader( int nPages, UsePropertySheetHandleArray dummy, PFNPROPSHEETCALLBACK pfnCallback /* = NULL */ ) {
  29. _InitData();
  30. this -> phpage = new HPROPSHEETPAGE[ nPages ];
  31. this -> dwFlags &= ~PSH_PROPSHEETPAGE;
  32. this -> nPages = nPages;
  33. _Set_pfnCallback( pfnCallback );
  34. #ifdef CPropertySheetHeader_ValidateParameters
  35. #endif // CPropertySheetHeader_ValidateParameters
  36. _Validate();
  37. }
  38. //--------------------------------------------------------------------------------------------------
  39. // CPropertySheetHeader::CPropertySheetHeader
  40. CPropertySheetHeader::CPropertySheetHeader( LPCPROPSHEETPAGE pPageVector, int nPages, PFNPROPSHEETCALLBACK pfnCallback /* = NULL */ )
  41. {
  42. _InitData();
  43. if( _Set_ppsp( pPageVector, nPages ) ) { assert( 0 ); return; }
  44. _Set_pfnCallback( pfnCallback );
  45. #ifdef CPropertySheetHeader_ValidateParameters
  46. #endif // CPropertySheetHeader_ValidateParameters
  47. _Validate();
  48. }
  49. //--------------------------------------------------------------------------------------------------
  50. // CPropertySheetHeader::CPropertySheetHeader
  51. // Note that we are assuming that you are telling us wether to use the ppsp or the phpage member
  52. // of PROPSHEETHEADER, as specified by the flag PSH_PROPSHEETPAGE
  53. CPropertySheetHeader::CPropertySheetHeader( int nPages, DWORD dwFlags, PFNPROPSHEETCALLBACK pfnCallback /* = NULL */ ) {
  54. _InitData();
  55. this -> dwFlags = dwFlags;
  56. if( this -> dwFlags & PSH_PROPSHEETPAGE ) {
  57. this -> ppsp = new PROPSHEETPAGE[ nPages ];
  58. this -> nPages = nPages;
  59. ZeroMemory( const_cast<LPPROPSHEETPAGE>( this -> ppsp ), sizeof( PROPSHEETPAGE ) * nPages );
  60. }
  61. else {
  62. this -> phpage = new HPROPSHEETPAGE[ nPages ];
  63. this -> nPages = nPages;
  64. ZeroMemory( this -> phpage, sizeof( HPROPSHEETPAGE ) * nPages );
  65. }
  66. _Set_pfnCallback( pfnCallback );
  67. _Validate();
  68. }
  69. //--------------------------------------------------------------------------------------------------
  70. // CPropertySheetHeader::~CPropertySheetHeader
  71. CPropertySheetHeader::~CPropertySheetHeader( void ) {
  72. _DeletePageData();
  73. }
  74. //--------------------------------------------------------------------------------------------------
  75. // CPropertySheetHeader::_InitData
  76. BOOL CPropertySheetHeader::_InitData( void ) {
  77. ZeroMemory( this, sizeof( PROPSHEETHEADER ) );
  78. this -> dwSize = sizeof( PROPSHEETHEADER );
  79. return TRUE;
  80. }
  81. ////////////////////////////////////////////////////////////////////////////////////////////////////
  82. // Methods and operators
  83. ////////////////////////////////////////////////////////////////////////////////////////////////////
  84. //--------------------------------------------------------------------------------------------------
  85. // CPropertySheetHeader::operator[]
  86. // This is a funny little beastie. Basically, it returns an iterator so the results can be used as
  87. // both an lval and an rval.
  88. //
  89. // MyPropertySheetPage = MyPropSheetHeader[ 0 ];
  90. // MyPropSheetHeader[ 1 ] = OtherPage;
  91. CPropertySheetHeader::CPropertySheetPageDataIterator CPropertySheetHeader::operator[]( int index ) {
  92. #ifdef CPropertySheetHeader_ValidateParameters
  93. assert( index >= 0 );
  94. if( static_cast< UINT >( index ) >= this -> nPages ) { // This is out of range ( they start at 0 )
  95. assert( 0 );
  96. return CPropertySheetPageDataIterator( 0, this );
  97. }
  98. #endif // CPropertySheetHeader_ValidateParameters
  99. return CPropertySheetPageDataIterator( index, this );
  100. }
  101. //--------------------------------------------------------------------------------------------------
  102. // CPropertySheetHeader::_Validate
  103. BOOL CPropertySheetHeader::_Validate( void ) {
  104. #ifdef CPropertySheetHeader_ValidateParameters
  105. if( ( this -> dwFlags & PSH_PROPTITLE ) || ( this -> dwFlags & PSH_USEICONID ) ) {
  106. if( NULL == this -> hInstance ) {
  107. assert( 0 );
  108. return FALSE;
  109. }
  110. }
  111. #endif // CPropertySheetHeader_ValidateParameters
  112. return TRUE;
  113. }
  114. //--------------------------------------------------------------------------------------------------
  115. // CPropertySheetHeader::_Set_hwndParent
  116. BOOL CPropertySheetHeader::_Set_hwndParent( HWND hwndParent ) {
  117. #ifdef CPropertySheetHeader_ValidateParameters
  118. #endif // CPropertySheetHeader_ValidateParameters
  119. this -> hwndParent = hwndParent;
  120. return TRUE;
  121. }
  122. BOOL CPropertySheetHeader::_Set_hInstance( HINSTANCE hInstance ) {
  123. #ifdef CPropertySheetHeader_ValidateParameters
  124. #endif // CPropertySheetHeader_ValidateParameters
  125. this -> hInstance = hInstance;
  126. return TRUE;
  127. }
  128. //--------------------------------------------------------------------------------------------------
  129. // CPropertySheetHeader::_Set_hIcon
  130. BOOL CPropertySheetHeader::_Set_hIcon( HICON hIcon ) {
  131. if( NULL == hIcon ) { return FALSE; }
  132. #ifdef CPropertySheetHeader_ValidateParameters
  133. #endif // CPropertySheetHeader_ValidateParameters
  134. this -> dwFlags &= ~PSH_USEICONID;
  135. this -> dwFlags |= PSH_USEHICON;
  136. this -> hIcon = hIcon;
  137. return TRUE;
  138. }
  139. //--------------------------------------------------------------------------------------------------
  140. // CPropertySheetHeader::_Set_pszIcon
  141. BOOL CPropertySheetHeader::_Set_pszIcon( LPCTSTR pszIcon ) {
  142. if( NULL == pszIcon ) { return FALSE; }
  143. #ifdef CPropertySheetHeader_ValidateParameters
  144. if( NULL == this -> hInstance ) { // This must be set first
  145. assert( 0 );
  146. return FALSE;
  147. }
  148. #endif // CPropertySheetHeader_ValidateParameters
  149. this -> dwFlags &= ~PSH_USEHICON;
  150. this -> dwFlags |= PSH_USEICONID;
  151. this -> pszIcon = pszIcon;
  152. return TRUE;
  153. }
  154. //--------------------------------------------------------------------------------------------------
  155. // CPropertySheetHeader::_Set_pszCaption
  156. BOOL CPropertySheetHeader::_Set_pszCaption( LPCTSTR pszCaption ) {
  157. if( NULL == pszCaption ) { return FALSE; }
  158. #ifdef CPropertySheetHeader_ValidateParameters
  159. if( NULL == this -> hInstance ) { // This must be set first
  160. assert( 0 );
  161. return FALSE;
  162. }
  163. #endif // CPropertySheetHeader_ValidateParameters
  164. this -> dwFlags |= PSH_PROPTITLE;
  165. this -> pszCaption = pszCaption;
  166. return TRUE;
  167. }
  168. //--------------------------------------------------------------------------------------------------
  169. // CPropertySheetHeader::_Set_nStartPage
  170. BOOL CPropertySheetHeader::_Set_nStartPage( UINT nStartPage ) {
  171. #ifdef CPropertySheetHeader_ValidateParameters
  172. if( ( nStartPage > 0 ) || ( nStartPage >= this -> nPages ) ) {
  173. assert( 0 );
  174. return FALSE;
  175. }
  176. #endif // CPropertySheetHeader_ValidateParameters
  177. this -> dwFlags &= ~PSH_USEPSTARTPAGE;
  178. this -> nStartPage = nStartPage;
  179. return TRUE;
  180. }
  181. //--------------------------------------------------------------------------------------------------
  182. // CPropertySheetHeader::_Set_pStartPage
  183. BOOL CPropertySheetHeader::_Set_pStartPage( LPCTSTR pStartPage ) {
  184. if( NULL == pStartPage ) { return FALSE; }
  185. #ifdef CPropertySheetHeader_ValidateParameters
  186. #endif // CPropertySheetHeader_ValidateParameters
  187. this -> dwFlags |= PSH_USEPSTARTPAGE;
  188. this -> pStartPage = pStartPage;
  189. return TRUE;
  190. }
  191. //--------------------------------------------------------------------------------------------------
  192. // CPropertySheetHeader::_Set_ppsp
  193. BOOL CPropertySheetHeader::_Set_ppsp( LPCPROPSHEETPAGE ppsp, UINT nPages ) {
  194. _DeletePageData();
  195. this -> ppsp = new PROPSHEETPAGE[ nPages ];
  196. this -> dwFlags |= PSH_PROPSHEETPAGE;
  197. #ifdef CPropertySheetHeader_ValidateParameters
  198. for( UINT i = 0; i < this -> nPages; i++ ) {
  199. const_cast<LPPROPSHEETPAGE>( this -> ppsp )[ i ] = CPropertySheetPage( ppsp + i );
  200. }
  201. #else
  202. memcpy( this -> ppsp, ppsp, sizeof( PROPSHEETPAGE ) * nPages );
  203. #endif // CPropertySheetHeader_ValidateParameters
  204. this -> nPages = nPages;
  205. return TRUE;
  206. }
  207. //--------------------------------------------------------------------------------------------------
  208. // CPropertySheetHeader::_Set_phpage
  209. BOOL CPropertySheetHeader::_Set_phpage( HPROPSHEETPAGE FAR phpage, UINT nPages ) {
  210. #ifdef CPropertySheetHeader_ValidateParameters
  211. #endif // CPropertySheetHeader_ValidateParameters
  212. _DeletePageData();
  213. this -> phpage = new HPROPSHEETPAGE[ nPages ];
  214. this -> dwFlags &= ~PSH_PROPSHEETPAGE;
  215. memcpy( this -> phpage, phpage, sizeof( HPROPSHEETPAGE ) * nPages );
  216. this -> nPages = nPages;
  217. return TRUE;
  218. }
  219. //--------------------------------------------------------------------------------------------------
  220. // CPropertySheetHeader::_Set_pfnCallback
  221. BOOL CPropertySheetHeader::_Set_pfnCallback( PFNPROPSHEETCALLBACK pfnCallback ) {
  222. #ifdef CPropertySheetHeader_ValidateParameters
  223. #endif // CPropertySheetHeader_ValidateParameters
  224. if( NULL != pfnCallback ) {
  225. this -> pfnCallback = pfnCallback;
  226. this -> dwFlags |= PSH_USECALLBACK;
  227. }
  228. return TRUE;
  229. }
  230. //--------------------------------------------------------------------------------------------------
  231. // CPropertySheetHeader::_DeletePageData
  232. BOOL CPropertySheetHeader::_DeletePageData( void ) {
  233. if( this -> dwFlags & PSH_PROPSHEETPAGE ) {
  234. LPPROPSHEETPAGE ppsp = const_cast<LPPROPSHEETPAGE>( this -> ppsp );
  235. delete [] ppsp;
  236. this -> ppsp = NULL;
  237. }
  238. else {
  239. delete [] const_cast<HPROPSHEETPAGE FAR *>( this -> phpage );
  240. this -> phpage = NULL;
  241. }
  242. this -> nPages = 0;
  243. return TRUE;
  244. }