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.

567 lines
14 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // LCPair.h
  7. //
  8. // Abstract:
  9. // Definition of the CModifyNodesDlg and CModifyResourcesDlg dialogs.
  10. //
  11. // Implementation File:
  12. // LCPair.cpp
  13. //
  14. // Author:
  15. // David Potter (davidp) April 16, 1998
  16. //
  17. // Revision History:
  18. //
  19. // Notes:
  20. //
  21. /////////////////////////////////////////////////////////////////////////////
  22. #ifndef __LCPAIR_H_
  23. #define __LCPAIR_H_
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Forward Class Declarations
  26. /////////////////////////////////////////////////////////////////////////////
  27. template < class T, class BaseT > class CModifyNodesDlg;
  28. template < class T, class BaseT > class CModifyResourcesDlg;
  29. class CModifyPreferredOwners;
  30. class CModifyPossibleOwners;
  31. class CModifyDependencies;
  32. /////////////////////////////////////////////////////////////////////////////
  33. // External Class Declarations
  34. /////////////////////////////////////////////////////////////////////////////
  35. class CClusGroupInfo;
  36. class CClusResInfo;
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Include Files
  39. /////////////////////////////////////////////////////////////////////////////
  40. #ifndef __CLUSOBJ_H_
  41. #include "ClusObj.h" // for CClusterObject, CClusObjPtrList
  42. #endif
  43. #ifndef __ATLLCPAIR_H_
  44. #include "AtlLCPair.h" // for CListCtrlPair
  45. #endif
  46. #ifndef __ATLBASEDLG_H_
  47. #include "AtlBaseDlg.h" // for CBaseDlg
  48. #endif
  49. #ifndef __HELPDATA_H_
  50. #include "HelpData.h" // for control id to help context id mapping array
  51. #endif
  52. /////////////////////////////////////////////////////////////////////////////
  53. // Type Definitions
  54. /////////////////////////////////////////////////////////////////////////////
  55. /////////////////////////////////////////////////////////////////////////////
  56. // class CModifyNodesDlg
  57. /////////////////////////////////////////////////////////////////////////////
  58. template < class T, class BaseT >
  59. class CModifyNodesDlg : public CListCtrlPair< T, CClusNodeInfo, BaseT >
  60. {
  61. typedef CModifyNodesDlg< T, BaseT > thisClass;
  62. typedef CListCtrlPair< T, CClusNodeInfo, BaseT > baseClass;
  63. public:
  64. //
  65. // Construction
  66. //
  67. // Constructor taking a string pointer for the title
  68. CModifyNodesDlg(
  69. IN CClusterAppWizard * pwiz,
  70. IN DWORD dwStyle,
  71. IN LPCTSTR pszTitle = NULL
  72. )
  73. : baseClass(
  74. dwStyle | /*LCPS_PROPERTIES_BUTTON | */(dwStyle & LCPS_ORDERED ? LCPS_CAN_BE_ORDERED : 0),
  75. pszTitle
  76. )
  77. {
  78. ASSERT( pwiz != NULL );
  79. m_pwiz = pwiz;
  80. } //*** CModifyNodesDlg()
  81. // Constructor taking a resource ID for the title
  82. CModifyNodesDlg(
  83. IN CClusterAppWizard * pwiz,
  84. IN DWORD dwStyle,
  85. IN UINT nIDCaption
  86. )
  87. : baseClass(
  88. dwStyle | /*LCPS_PROPERTIES_BUTTON | */(dwStyle & LCPS_ORDERED ? LCPS_CAN_BE_ORDERED : 0),
  89. nIDCaption
  90. )
  91. {
  92. ASSERT( pwiz != NULL );
  93. m_pwiz = pwiz;
  94. } //*** CModifyNodesDlg()
  95. protected:
  96. CClusterAppWizard * m_pwiz;
  97. public:
  98. CClusterAppWizard * Pwiz( void ) const { return m_pwiz; }
  99. public:
  100. //
  101. // Functions that are required to be implemented by CListCtrlPair.
  102. //
  103. // Get column text and image
  104. void GetColumnInfo(
  105. IN OUT CClusNodeInfo * pobj,
  106. IN int iItem,
  107. IN int icol,
  108. OUT CString & rstr,
  109. OUT int * piimg
  110. )
  111. {
  112. switch ( icol )
  113. {
  114. case 0:
  115. rstr = pobj->RstrName();
  116. break;
  117. default:
  118. ASSERT( 0 );
  119. break;
  120. } // switch: icol
  121. } //*** GetColumnInfo()
  122. // Display an application-wide message box
  123. virtual int AppMessageBox( LPCWSTR lpszText, UINT fuStyle )
  124. {
  125. return ::AppMessageBox( m_hWnd, lpszText, fuStyle );
  126. } //*** AppMessageBox()
  127. public:
  128. //
  129. // Message map.
  130. //
  131. // BEGIN_MSG_MAP( thisClass )
  132. // CHAIN_MSG_MAP( baseClass )
  133. // END_MSG_MAP()
  134. //
  135. // Message handler functions.
  136. //
  137. //
  138. // Message handler overrides.
  139. //
  140. // Handler for the WM_INITDIALOG message
  141. BOOL OnInitDialog( void )
  142. {
  143. //
  144. // Add columns.
  145. //
  146. AddColumn( IDS_COLTEXT_NODE_NAME, 125 /* nWidth */);
  147. //
  148. // Call the base class.
  149. //
  150. return baseClass::OnInitDialog();
  151. } //*** OnInitDialog()
  152. //static const DWORD * PidHelpMap( void ) { return g_; };
  153. }; //*** class CModifyNodesDlg
  154. /////////////////////////////////////////////////////////////////////////////
  155. // class CModifyResourcesDlg
  156. /////////////////////////////////////////////////////////////////////////////
  157. template < class T, class BaseT >
  158. class CModifyResourcesDlg : public CListCtrlPair< T, CClusResInfo, BaseT >
  159. {
  160. typedef CModifyResourcesDlg< T, BaseT > thisClass;
  161. typedef CListCtrlPair< T, CClusResInfo, BaseT > baseClass;
  162. public:
  163. //
  164. // Construction
  165. //
  166. // Constructor taking a string pointer for the title
  167. CModifyResourcesDlg(
  168. IN CClusterAppWizard * pwiz,
  169. IN DWORD dwStyle,
  170. IN LPCTSTR pszTitle = NULL
  171. )
  172. : baseClass(
  173. dwStyle | /*LCPS_PROPERTIES_BUTTON | */(dwStyle & LCPS_ORDERED ? LCPS_CAN_BE_ORDERED : 0),
  174. pszTitle
  175. )
  176. , m_pwiz( pwiz )
  177. {
  178. ASSERT( pwiz != NULL);
  179. } //*** CModifyResourcesDlg()
  180. // Constructor taking a resource ID for the title
  181. CModifyResourcesDlg(
  182. IN CClusterAppWizard * pwiz,
  183. IN DWORD dwStyle,
  184. IN UINT nIDCaption
  185. )
  186. : baseClass(
  187. dwStyle | /*LCPS_PROPERTIES_BUTTON | */(dwStyle & LCPS_ORDERED ? LCPS_CAN_BE_ORDERED : 0),
  188. nIDCaption
  189. )
  190. , m_pwiz( pwiz )
  191. {
  192. ASSERTE( pwiz != NULL );
  193. } //*** CModifyResourcesDlg()
  194. protected:
  195. CClusterAppWizard * m_pwiz;
  196. public:
  197. CClusterAppWizard * Pwiz( void ) const { return m_pwiz; }
  198. public:
  199. //
  200. // Functions that are required to be implemented by CListCtrlPair.
  201. //
  202. // Get column text and image
  203. void GetColumnInfo(
  204. IN OUT CClusResInfo * pobj,
  205. IN int iItem,
  206. IN int icol,
  207. OUT CString & rstr,
  208. OUT int * piimg
  209. )
  210. {
  211. switch ( icol )
  212. {
  213. case 0:
  214. rstr = pobj->RstrName();
  215. break;
  216. case 1:
  217. rstr = pobj->Prti()->RstrDisplayName();
  218. break;
  219. default:
  220. ASSERT( 0 );
  221. break;
  222. } // switch: icol
  223. } //*** GetColumnInfo()
  224. // Display an application-wide message box
  225. virtual int AppMessageBox( LPCWSTR lpszText, UINT fuStyle )
  226. {
  227. return ::AppMessageBox( m_hWnd, lpszText, fuStyle );
  228. } //*** AppMessageBox()
  229. public:
  230. //
  231. // Message map.
  232. //
  233. // BEGIN_MSG_MAP( thisClass )
  234. // CHAIN_MSG_MAP( baseClass )
  235. // END_MSG_MAP()
  236. //
  237. // Message handler functions.
  238. //
  239. //
  240. // Message handler overrides.
  241. //
  242. // Handler for the WM_INITDIALOG message
  243. BOOL OnInitDialog( void )
  244. {
  245. //
  246. // Add columns.
  247. //
  248. AddColumn( IDS_COLTEXT_RESOURCE_NAME, 125 /* nWidth */);
  249. AddColumn( IDS_COLTEXT_RESOURCE_TYPE, 100 /* nWidth */);
  250. //
  251. // Call the base class.
  252. //
  253. return baseClass::OnInitDialog();
  254. } //*** OnInitDialog()
  255. //static const DWORD * PidHelpMap( void ) { return g_; };
  256. }; //*** class CModifyResourcesDlg
  257. /////////////////////////////////////////////////////////////////////////////
  258. // class CModifyPreferredOwners
  259. /////////////////////////////////////////////////////////////////////////////
  260. class CModifyPreferredOwners : public CModifyNodesDlg< CModifyPreferredOwners, CBaseDlg< CModifyPreferredOwners > >
  261. {
  262. typedef CModifyNodesDlg< CModifyPreferredOwners, CBaseDlg< CModifyPreferredOwners > > baseClass;
  263. public:
  264. // Constructor
  265. CModifyPreferredOwners(
  266. IN CClusterAppWizard * pwiz,
  267. IN CClusGroupInfo * pgi,
  268. IN OUT CClusNodePtrList * plpniRight,
  269. IN CClusNodePtrList * plpniLeft
  270. )
  271. : baseClass( pwiz, LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY | LCPS_CAN_BE_ORDERED | LCPS_ORDERED )
  272. , m_pgi( pgi )
  273. , m_plpniRight( plpniRight )
  274. , m_plpniLeft( plpniLeft )
  275. {
  276. ASSERT( pgi != NULL );
  277. ASSERT( plpniRight != NULL );
  278. ASSERT( plpniLeft != NULL );
  279. } //*** CModifyPreferredOwners()
  280. enum { IDD = IDD_MODIFY_PREFERRED_OWNERS };
  281. DECLARE_CTRL_NAME_MAP()
  282. protected:
  283. CClusGroupInfo * m_pgi;
  284. CClusNodePtrList * m_plpniRight;
  285. CClusNodePtrList * m_plpniLeft;
  286. public:
  287. //
  288. // Functions that are required to be implemented by CListCtrlPair.
  289. //
  290. // Return list of objects for right list control
  291. CClusNodePtrList * PlpobjRight( void ) const
  292. {
  293. return m_plpniRight;
  294. } //*** PlpobjRight()
  295. // Return list of objects for left list control
  296. CClusNodePtrList * PlpobjLeft( void ) const
  297. {
  298. return m_plpniLeft;
  299. } //*** PlpobjRight()
  300. static const DWORD * PidHelpMap( void ) { return g_aHelpIDs_IDD_MODIFY_PREFERRED_OWNERS; };
  301. }; //*** class CModifyPreferredOwners
  302. /////////////////////////////////////////////////////////////////////////////
  303. // class CModifyPossibleOwners
  304. /////////////////////////////////////////////////////////////////////////////
  305. class CModifyPossibleOwners : public CModifyNodesDlg< CModifyPossibleOwners, CBaseDlg< CModifyPossibleOwners > >
  306. {
  307. typedef CModifyNodesDlg< CModifyPossibleOwners, CBaseDlg< CModifyPossibleOwners > > baseClass;
  308. public:
  309. // Constructor
  310. CModifyPossibleOwners(
  311. IN CClusterAppWizard * pwiz,
  312. IN CClusResInfo * pri,
  313. IN OUT CClusNodePtrList * plpniRight,
  314. IN CClusNodePtrList * plpniLeft
  315. )
  316. : baseClass( pwiz, LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY )
  317. , m_pri( pri )
  318. , m_plpniRight( plpniRight )
  319. , m_plpniLeft( plpniLeft )
  320. {
  321. ASSERT( pri != NULL );
  322. ASSERT( plpniRight != NULL );
  323. ASSERT( plpniLeft != NULL );
  324. } //*** CModifyPossibleOwners()
  325. enum { IDD = IDD_MODIFY_POSSIBLE_OWNERS };
  326. DECLARE_CTRL_NAME_MAP()
  327. protected:
  328. CClusResInfo * m_pri;
  329. CClusNodePtrList * m_plpniRight;
  330. CClusNodePtrList * m_plpniLeft;
  331. public:
  332. //
  333. // Functions that are required to be implemented by CListCtrlPair.
  334. //
  335. // Return list of objects for right list control
  336. CClusNodePtrList * PlpobjRight( void ) const
  337. {
  338. return m_plpniRight;
  339. } //*** PlpobjRight()
  340. // Return list of objects for left list control
  341. CClusNodePtrList * PlpobjLeft( void ) const
  342. {
  343. return m_plpniLeft;
  344. } //*** PlpobjRight()
  345. static const DWORD * PidHelpMap( void ) { return g_aHelpIDs_IDD_MODIFY_POSSIBLE_OWNERS; };
  346. }; //*** class CModifyPossibleOwners
  347. /////////////////////////////////////////////////////////////////////////////
  348. // class CModifyDependencies
  349. /////////////////////////////////////////////////////////////////////////////
  350. class CModifyDependencies
  351. : public CModifyResourcesDlg< CModifyDependencies, CBaseDlg< CModifyDependencies > >
  352. {
  353. typedef CModifyResourcesDlg< CModifyDependencies, CBaseDlg< CModifyDependencies > > baseClass;
  354. public:
  355. // Constructor
  356. CModifyDependencies(
  357. IN CClusterAppWizard * pwiz,
  358. IN CClusResInfo * pri,
  359. IN OUT CClusResPtrList * plpriRight,
  360. IN CClusResPtrList * plpriLeft
  361. )
  362. : baseClass( pwiz, LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY )
  363. , m_pri( pri )
  364. , m_plpriRight( plpriRight )
  365. , m_plpriLeft( plpriLeft )
  366. {
  367. ASSERT( pri != NULL );
  368. ASSERT( plpriRight != NULL );
  369. ASSERT( plpriLeft != NULL );
  370. } //*** CModifyDependencies()
  371. enum { IDD = IDD_MODIFY_DEPENDENCIES };
  372. DECLARE_CTRL_NAME_MAP()
  373. protected:
  374. CClusResInfo * m_pri;
  375. CClusResPtrList * m_plpriRight;
  376. CClusResPtrList * m_plpriLeft;
  377. public:
  378. //
  379. // Functions that are required to be implemented by CListCtrlPair.
  380. //
  381. // Return list of objects for right list control
  382. CClusResPtrList * PlpobjRight( void ) const
  383. {
  384. return m_plpriRight;
  385. } //*** PlpobjRight()
  386. // Return list of objects for left list control
  387. CClusResPtrList * PlpobjLeft( void ) const
  388. {
  389. return m_plpriLeft;
  390. } //*** PlpobjRight()
  391. // Update data on or from the dialog
  392. BOOL UpdateData( IN BOOL bSaveAndValidate )
  393. {
  394. BOOL bSuccess = TRUE;
  395. bSuccess = baseClass::UpdateData( bSaveAndValidate );
  396. if ( bSuccess )
  397. {
  398. if ( bSaveAndValidate )
  399. {
  400. //
  401. // Ensure all required dependencies are present.
  402. //
  403. if ( ! Pwiz()->BRequiredDependenciesPresent( m_pri, &LpobjRight() ) )
  404. {
  405. bSuccess = FALSE;
  406. } // if: all required dependencies not present
  407. } // if: saving data from the dialog
  408. } // if: base class was successful
  409. return bSuccess;
  410. } //*** UpdateData()
  411. static const DWORD * PidHelpMap( void ) { return g_aHelpIDs_IDD_MODIFY_DEPENDENCIES; };
  412. }; //*** class CModifyDependencies
  413. /////////////////////////////////////////////////////////////////////////////
  414. // Global Variables
  415. /////////////////////////////////////////////////////////////////////////////
  416. /////////////////////////////////////////////////////////////////////////////
  417. // CModifyPreferredOwners Control Name Map
  418. BEGIN_CTRL_NAME_MAP( CModifyPreferredOwners )
  419. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LABEL )
  420. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LIST )
  421. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_ADD )
  422. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_REMOVE )
  423. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LABEL )
  424. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LIST )
  425. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_MOVE_UP )
  426. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_MOVE_DOWN )
  427. DEFINE_CTRL_NAME_MAP_ENTRY( IDOK )
  428. DEFINE_CTRL_NAME_MAP_ENTRY( IDCANCEL )
  429. END_CTRL_NAME_MAP()
  430. /////////////////////////////////////////////////////////////////////////////
  431. // CModifyPossibleOwners Control Name Map
  432. BEGIN_CTRL_NAME_MAP( CModifyPossibleOwners )
  433. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LABEL )
  434. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LIST )
  435. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_ADD )
  436. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_REMOVE )
  437. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LABEL )
  438. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LIST )
  439. DEFINE_CTRL_NAME_MAP_ENTRY( IDOK )
  440. DEFINE_CTRL_NAME_MAP_ENTRY( IDCANCEL )
  441. END_CTRL_NAME_MAP()
  442. /////////////////////////////////////////////////////////////////////////////
  443. // CModifyDependencies Control Name Map
  444. BEGIN_CTRL_NAME_MAP( CModifyDependencies )
  445. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LABEL )
  446. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_LEFT_LIST )
  447. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_ADD )
  448. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_REMOVE )
  449. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LABEL )
  450. DEFINE_CTRL_NAME_MAP_ENTRY( ADMC_IDC_LCP_RIGHT_LIST )
  451. DEFINE_CTRL_NAME_MAP_ENTRY( IDOK )
  452. DEFINE_CTRL_NAME_MAP_ENTRY( IDCANCEL )
  453. END_CTRL_NAME_MAP()
  454. /////////////////////////////////////////////////////////////////////////////
  455. #endif // __LCPAIR_H_