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.

1302 lines
39 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // GrpProp.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the group property sheet and pages.
  10. //
  11. // Author:
  12. // David Potter (davidp) May 14, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "GrpProp.h"
  21. #include "Group.h"
  22. #include "ModNodes.h"
  23. #include "DDxDDv.h"
  24. #include "ClusDoc.h"
  25. #include "HelpData.h" // for g_rghelpmap*
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CGroupPropSheet
  33. /////////////////////////////////////////////////////////////////////////////
  34. IMPLEMENT_DYNAMIC(CGroupPropSheet, CBasePropertySheet)
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Message Maps
  37. BEGIN_MESSAGE_MAP(CGroupPropSheet, CBasePropertySheet)
  38. //{{AFX_MSG_MAP(CGroupPropSheet)
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. //++
  43. //
  44. // CGroupPropSheet::CGroupPropSheet
  45. //
  46. // Routine Description:
  47. // Constructor.
  48. //
  49. // Arguments:
  50. // pci [IN OUT] Cluster item whose properties are to be displayed.
  51. // pParentWnd [IN OUT] Parent window for this property sheet.
  52. // iSelectPage [IN] Page to show first.
  53. //
  54. // Return Value:
  55. // None.
  56. //
  57. //--
  58. /////////////////////////////////////////////////////////////////////////////
  59. CGroupPropSheet::CGroupPropSheet(
  60. IN OUT CWnd * pParentWnd,
  61. IN UINT iSelectPage
  62. )
  63. : CBasePropertySheet(pParentWnd, iSelectPage)
  64. {
  65. m_rgpages[0] = &PageGeneral();
  66. m_rgpages[1] = &PageFailover();
  67. m_rgpages[2] = &PageFailback();
  68. } //*** CGroupPropSheet::CGroupPropSheet()
  69. /////////////////////////////////////////////////////////////////////////////
  70. //++
  71. //
  72. // CGroupPropSheet::BInit
  73. //
  74. // Routine Description:
  75. // Initialize the property sheet.
  76. //
  77. // Arguments:
  78. // pci [IN OUT] Cluster item whose properties are to be displayed.
  79. // iimgIcon [IN] Index in the large image list for the image to use
  80. // as the icon on each page.
  81. //
  82. // Return Value:
  83. // TRUE Property sheet initialized successfully.
  84. // FALSE Error initializing property sheet.
  85. //
  86. //--
  87. /////////////////////////////////////////////////////////////////////////////
  88. BOOL CGroupPropSheet::BInit(
  89. IN OUT CClusterItem * pci,
  90. IN IIMG iimgIcon
  91. )
  92. {
  93. // Call the base class method.
  94. if (!CBasePropertySheet::BInit(pci, iimgIcon))
  95. {
  96. return FALSE;
  97. }
  98. // Set the read-only flag.
  99. m_bReadOnly = PciGroup()->BReadOnly()
  100. || (PciGroup()->Cgs() == ClusterGroupStateUnknown);
  101. return TRUE;
  102. } //*** CGroupPropSheet::BInit()
  103. /////////////////////////////////////////////////////////////////////////////
  104. //++
  105. //
  106. // CGroupPropSheet::Ppages
  107. //
  108. // Routine Description:
  109. // Returns the array of pages to add to the property sheet.
  110. //
  111. // Arguments:
  112. // None.
  113. //
  114. // Return Value:
  115. // Page array.
  116. //
  117. //--
  118. /////////////////////////////////////////////////////////////////////////////
  119. CBasePropertyPage ** CGroupPropSheet::Ppages(void)
  120. {
  121. return m_rgpages;
  122. } //*** CGroupPropSheet::Ppages()
  123. /////////////////////////////////////////////////////////////////////////////
  124. //++
  125. //
  126. // CGroupPropSheet::Cpages
  127. //
  128. // Routine Description:
  129. // Returns the count of pages in the array.
  130. //
  131. // Arguments:
  132. // None.
  133. //
  134. // Return Value:
  135. // Count of pages in the array.
  136. //
  137. //--
  138. /////////////////////////////////////////////////////////////////////////////
  139. int CGroupPropSheet::Cpages(void)
  140. {
  141. return RTL_NUMBER_OF( m_rgpages );
  142. } //*** CGroupPropSheet::Cpages()
  143. //*************************************************************************//
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CGroupGeneralPage property page
  146. /////////////////////////////////////////////////////////////////////////////
  147. IMPLEMENT_DYNCREATE(CGroupGeneralPage, CBasePropertyPage)
  148. /////////////////////////////////////////////////////////////////////////////
  149. // Message Maps
  150. /////////////////////////////////////////////////////////////////////////////
  151. BEGIN_MESSAGE_MAP(CGroupGeneralPage, CBasePropertyPage)
  152. //{{AFX_MSG_MAP(CGroupGeneralPage)
  153. ON_BN_CLICKED(IDC_PP_GROUP_PREF_OWNERS_MODIFY, OnModifyPreferredOwners)
  154. ON_LBN_DBLCLK(IDC_PP_GROUP_PREF_OWNERS, OnDblClkPreferredOwners)
  155. ON_WM_CONTEXTMENU()
  156. //}}AFX_MSG_MAP
  157. ON_EN_CHANGE(IDC_PP_GROUP_NAME, CBasePropertyPage::OnChangeCtrl)
  158. ON_EN_CHANGE(IDC_PP_GROUP_DESC, CBasePropertyPage::OnChangeCtrl)
  159. ON_COMMAND(ID_FILE_PROPERTIES, OnProperties)
  160. END_MESSAGE_MAP()
  161. /////////////////////////////////////////////////////////////////////////////
  162. //++
  163. //
  164. // CGroupGeneralPage::CGroupGeneralPage
  165. //
  166. // Routine Description:
  167. // Constructor.
  168. //
  169. // Arguments:
  170. // None.
  171. //
  172. // Return Value:
  173. // None.
  174. //
  175. //--
  176. /////////////////////////////////////////////////////////////////////////////
  177. CGroupGeneralPage::CGroupGeneralPage(void)
  178. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_GROUP_GENERAL)
  179. {
  180. //{{AFX_DATA_INIT(CGroupGeneralPage)
  181. m_strName = _T("");
  182. m_strDesc = _T("");
  183. m_strState = _T("");
  184. m_strNode = _T("");
  185. //}}AFX_DATA_INIT
  186. } //*** CGroupGeneralPage::CGroupGeneralPage()
  187. /////////////////////////////////////////////////////////////////////////////
  188. //++
  189. //
  190. // CGroupGeneralPage::BInit
  191. //
  192. // Routine Description:
  193. // Initialize the page.
  194. //
  195. // Arguments:
  196. // psht [IN OUT] Property sheet to which this page belongs.
  197. //
  198. // Return Value:
  199. // TRUE Page initialized successfully.
  200. // FALSE Page failed to initialize.
  201. //
  202. //--
  203. /////////////////////////////////////////////////////////////////////////////
  204. BOOL CGroupGeneralPage::BInit(IN OUT CBaseSheet * psht)
  205. {
  206. BOOL bSuccess;
  207. ASSERT_KINDOF(CGroupPropSheet, psht);
  208. bSuccess = CBasePropertyPage::BInit(psht);
  209. if (bSuccess)
  210. {
  211. try
  212. {
  213. m_strName = PciGroup()->StrName();
  214. m_strDesc = PciGroup()->StrDescription();
  215. m_strNode = PciGroup()->StrOwner();
  216. // Duplicate the preferred owners list.
  217. {
  218. POSITION pos;
  219. CClusterNode * pciNode;
  220. pos = PciGroup()->LpcinodePreferredOwners().GetHeadPosition();
  221. while (pos != NULL)
  222. {
  223. pciNode = (CClusterNode *) PciGroup()->LpcinodePreferredOwners().GetNext(pos);
  224. ASSERT_VALID(pciNode);
  225. m_lpciPreferredOwners.AddTail(pciNode);
  226. } // while: more nodes in the list
  227. } // Duplicate the possible owners list
  228. PciGroup()->GetStateName(m_strState);
  229. } // try
  230. catch (CException * pe)
  231. {
  232. pe->ReportError();
  233. pe->Delete();
  234. bSuccess = FALSE;
  235. } // catch: CException
  236. } // if: base class method was successful
  237. return bSuccess;
  238. } //*** CGroupGeneralPage::BInit()
  239. /////////////////////////////////////////////////////////////////////////////
  240. //++
  241. //
  242. // CGroupGeneralPage::DoDataExchange
  243. //
  244. // Routine Description:
  245. // Do data exchange between the dialog and the class.
  246. //
  247. // Arguments:
  248. // pDX [IN OUT] Data exchange object
  249. //
  250. // Return Value:
  251. // None.
  252. //
  253. //--
  254. /////////////////////////////////////////////////////////////////////////////
  255. void CGroupGeneralPage::DoDataExchange(CDataExchange * pDX)
  256. {
  257. CBasePropertyPage::DoDataExchange(pDX);
  258. //{{AFX_DATA_MAP(CGroupGeneralPage)
  259. DDX_Control(pDX, IDC_PP_GROUP_PREF_OWNERS_MODIFY, m_pbPrefOwnersModify);
  260. DDX_Control(pDX, IDC_PP_GROUP_PREF_OWNERS, m_lbPrefOwners);
  261. DDX_Control(pDX, IDC_PP_GROUP_DESC, m_editDesc);
  262. DDX_Control(pDX, IDC_PP_GROUP_NAME, m_editName);
  263. DDX_Text(pDX, IDC_PP_GROUP_NAME, m_strName);
  264. DDX_Text(pDX, IDC_PP_GROUP_DESC, m_strDesc);
  265. DDX_Text(pDX, IDC_PP_GROUP_CURRENT_STATE, m_strState);
  266. DDX_Text(pDX, IDC_PP_GROUP_CURRENT_NODE, m_strNode);
  267. //}}AFX_DATA_MAP
  268. if (pDX->m_bSaveAndValidate)
  269. {
  270. if (!BReadOnly())
  271. {
  272. DDV_RequiredText(pDX, IDC_PP_GROUP_NAME, IDC_PP_GROUP_NAME_LABEL, m_strName);
  273. try
  274. {
  275. PciGroup()->ValidateCommonProperties(
  276. m_strDesc,
  277. PciGroup()->NFailoverThreshold(),
  278. PciGroup()->NFailoverPeriod(),
  279. PciGroup()->CgaftAutoFailbackType(),
  280. PciGroup()->NFailbackWindowStart(),
  281. PciGroup()->NFailbackWindowEnd()
  282. );
  283. } // try
  284. catch (CException * pe)
  285. {
  286. pe->ReportError();
  287. pe->Delete();
  288. pDX->Fail();
  289. } // catch: CException
  290. } // if: not read only
  291. } // if: saving data from dialog
  292. else
  293. {
  294. FillPrefOwners();
  295. } // else: setting data to dialog
  296. } //*** CGroupGeneralPage::DoDataExchange()
  297. /////////////////////////////////////////////////////////////////////////////
  298. //++
  299. //
  300. // CGroupGeneralPage::FillPrefOwners
  301. //
  302. // Routine Description:
  303. // Fill the Preferred Owners list box.
  304. //
  305. // Arguments:
  306. // None.
  307. //
  308. // Return Value:
  309. // None.
  310. //
  311. //--
  312. /////////////////////////////////////////////////////////////////////////////
  313. void CGroupGeneralPage::FillPrefOwners(void)
  314. {
  315. POSITION posPci;
  316. CClusterNode * pciNode;
  317. int iitem;
  318. m_lbPrefOwners.ResetContent();
  319. posPci = LpciPreferredOwners().GetHeadPosition();
  320. while (posPci != NULL)
  321. {
  322. pciNode = (CClusterNode *) LpciPreferredOwners().GetNext(posPci);
  323. iitem = m_lbPrefOwners.AddString(pciNode->StrName());
  324. if (iitem >= 0)
  325. {
  326. m_lbPrefOwners.SetItemDataPtr(iitem, pciNode);
  327. }
  328. } // for: each string in the list
  329. } //*** CGroupGeneralPage::FillPrefOwners()
  330. /////////////////////////////////////////////////////////////////////////////
  331. //++
  332. //
  333. // CGroupGeneralPage::OnInitDialog
  334. //
  335. // Routine Description:
  336. // Handler for the WM_INITDIALOG message.
  337. //
  338. // Arguments:
  339. // None.
  340. //
  341. // Return Value:
  342. // TRUE Focus needs to be set.
  343. // FALSE Focus already set.
  344. //
  345. //--
  346. /////////////////////////////////////////////////////////////////////////////
  347. BOOL CGroupGeneralPage::OnInitDialog(void)
  348. {
  349. CBasePropertyPage::OnInitDialog();
  350. // If read-only, set all controls to be either disabled or read-only.
  351. if (BReadOnly())
  352. {
  353. m_editName.SetReadOnly(TRUE);
  354. m_editDesc.SetReadOnly(TRUE);
  355. m_pbPrefOwnersModify.EnableWindow(FALSE);
  356. } // if: sheet is read-only
  357. return TRUE; // return TRUE unless you set the focus to a control
  358. // EXCEPTION: OCX Property Pages should return FALSE
  359. } //*** CGroupGeneralPage::OnInitDialog()
  360. /////////////////////////////////////////////////////////////////////////////
  361. //++
  362. //
  363. // CGroupGeneralPage::OnApply
  364. //
  365. // Routine Description:
  366. // Handler for when the Apply button is pressed.
  367. //
  368. // Arguments:
  369. // None.
  370. //
  371. // Return Value:
  372. // TRUE Page successfully applied.
  373. // FALSE Error applying page.
  374. //
  375. //--
  376. /////////////////////////////////////////////////////////////////////////////
  377. BOOL CGroupGeneralPage::OnApply(void)
  378. {
  379. // Set the data from the page in the cluster item.
  380. try
  381. {
  382. CWaitCursor wc;
  383. PciGroup()->SetName(m_strName);
  384. PciGroup()->SetCommonProperties(
  385. m_strDesc,
  386. PciGroup()->NFailoverThreshold(),
  387. PciGroup()->NFailoverPeriod(),
  388. PciGroup()->CgaftAutoFailbackType(),
  389. PciGroup()->NFailbackWindowStart(),
  390. PciGroup()->NFailbackWindowEnd()
  391. );
  392. PciGroup()->SetPreferredOwners(m_lpciPreferredOwners);
  393. } // try
  394. catch (CException * pe)
  395. {
  396. pe->ReportError();
  397. pe->Delete();
  398. return FALSE;
  399. } // catch: CException
  400. return CBasePropertyPage::OnApply();
  401. } //*** CGroupGeneralPage::OnApply()
  402. /////////////////////////////////////////////////////////////////////////////
  403. //++
  404. //
  405. // CGroupGeneralPage::OnProperties
  406. //
  407. // Routine Description:
  408. // Handler for the BN_CLICKED message on the Properties button.
  409. //
  410. // Arguments:
  411. // None.
  412. //
  413. // Return Value:
  414. // None.
  415. //
  416. //--
  417. /////////////////////////////////////////////////////////////////////////////
  418. void CGroupGeneralPage::OnProperties(void)
  419. {
  420. int iitem;
  421. CClusterNode * pciNode;
  422. // Get the item with the focus.
  423. iitem = m_lbPrefOwners.GetCurSel();
  424. ASSERT(iitem >= 0);
  425. if (iitem >= 0)
  426. {
  427. // Get the node pointer.
  428. pciNode = (CClusterNode *) m_lbPrefOwners.GetItemDataPtr(iitem);
  429. ASSERT_VALID(pciNode);
  430. // Set properties of that item.
  431. if (pciNode->BDisplayProperties())
  432. {
  433. } // if: properties changed
  434. } // if: found an item with focus
  435. } //*** CGroupGeneralPage::OnProperties()
  436. /////////////////////////////////////////////////////////////////////////////
  437. //++
  438. //
  439. // CGroupGeneralPage::OnContextMenu
  440. //
  441. // Routine Description:
  442. // Handler for the WM_CONTEXTMENU method.
  443. //
  444. // Arguments:
  445. // pWnd Window in which the user right clicked the mouse.
  446. // point Position of the cursor, in screen coordinates.
  447. //
  448. // Return Value:
  449. // None.
  450. //
  451. //--
  452. /////////////////////////////////////////////////////////////////////////////
  453. void CGroupGeneralPage::OnContextMenu( CWnd * pWnd, CPoint point )
  454. {
  455. BOOL bHandled = FALSE;
  456. CMenu * pmenu = NULL;
  457. CListBox * pListBox = (CListBox *) pWnd;
  458. CString strMenuName;
  459. CWaitCursor wc;
  460. // If focus is not in the list control, don't handle the message.
  461. if ( pWnd == &m_lbPrefOwners )
  462. {
  463. // Create the menu to display.
  464. try
  465. {
  466. pmenu = new CMenu;
  467. if ( pmenu == NULL )
  468. {
  469. AfxThrowMemoryException();
  470. } // if: error allocating the menu
  471. if ( pmenu->CreatePopupMenu() )
  472. {
  473. UINT nFlags = MF_STRING;
  474. // If there are no items in the list, disable the menu item.
  475. if ( pListBox->GetCount() == 0 )
  476. {
  477. nFlags |= MF_GRAYED;
  478. } // if: no items in the list
  479. // Add the Properties item to the menu.
  480. strMenuName.LoadString( IDS_MENU_PROPERTIES );
  481. if ( pmenu->AppendMenu( nFlags, ID_FILE_PROPERTIES, strMenuName ) )
  482. {
  483. bHandled = TRUE;
  484. if ( pListBox->GetCurSel() == -1 )
  485. {
  486. pListBox->SetCurSel( 0 );
  487. } // if: no item selected
  488. } // if: successfully added menu item
  489. } // if: menu created successfully
  490. } // try
  491. catch ( CException * pe )
  492. {
  493. pe->ReportError();
  494. pe->Delete();
  495. } // catch: CException
  496. } // if: focus is on the list control
  497. if ( bHandled )
  498. {
  499. // Display the menu.
  500. if ( ! pmenu->TrackPopupMenu(
  501. TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  502. point.x,
  503. point.y,
  504. this
  505. ) )
  506. {
  507. } // if: unsuccessfully displayed the menu
  508. } // if: there is a menu to display
  509. else
  510. {
  511. CBasePropertyPage::OnContextMenu( pWnd, point );
  512. } // else: no menu to display
  513. delete pmenu;
  514. } //*** CGroupGeneralPage::OnContextMenu()
  515. /////////////////////////////////////////////////////////////////////////////
  516. //++
  517. //
  518. // CGroupGeneralPage::OnModifyPreferredOwners
  519. //
  520. // Routine Description:
  521. // Handler for the BN_CLICKED message on the Modify Preferred Owners button.
  522. //
  523. // Arguments:
  524. // None.
  525. //
  526. // Return Value:
  527. // None.
  528. //
  529. //--
  530. /////////////////////////////////////////////////////////////////////////////
  531. void CGroupGeneralPage::OnModifyPreferredOwners(void)
  532. {
  533. CModifyNodesDlg dlg(
  534. IDD_MODIFY_PREFERRED_OWNERS,
  535. g_aHelpIDs_IDD_MODIFY_PREFERRED_OWNERS,
  536. m_lpciPreferredOwners,
  537. PciGroup()->Pdoc()->LpciNodes(),
  538. LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY | LCPS_CAN_BE_ORDERED | LCPS_ORDERED
  539. );
  540. if (dlg.DoModal() == IDOK)
  541. {
  542. SetModified(TRUE);
  543. FillPrefOwners();
  544. } // if: OK button pressed
  545. } //*** CGroupGeneralPage::OnModifyPreferredOwners()
  546. /////////////////////////////////////////////////////////////////////////////
  547. //++
  548. //
  549. // CGroupGeneralPage::OnDblClkPreferredOwners
  550. //
  551. // Routine Description:
  552. // Handler for the LBN_DBLCLK message on the Preferred Owners listbox.
  553. //
  554. // Arguments:
  555. // None.
  556. //
  557. // Return Value:
  558. // None.
  559. //
  560. //--
  561. /////////////////////////////////////////////////////////////////////////////
  562. void CGroupGeneralPage::OnDblClkPreferredOwners(void)
  563. {
  564. OnProperties();
  565. } //*** CGroupGeneralPage::OnDblClkPreferredOwners()
  566. //*************************************************************************//
  567. /////////////////////////////////////////////////////////////////////////////
  568. // CGroupFailoverPage property page
  569. /////////////////////////////////////////////////////////////////////////////
  570. IMPLEMENT_DYNCREATE(CGroupFailoverPage, CBasePropertyPage)
  571. /////////////////////////////////////////////////////////////////////////////
  572. // Message Maps
  573. /////////////////////////////////////////////////////////////////////////////
  574. BEGIN_MESSAGE_MAP(CGroupFailoverPage, CBasePropertyPage)
  575. //{{AFX_MSG_MAP(CGroupFailoverPage)
  576. //}}AFX_MSG_MAP
  577. ON_EN_CHANGE(IDC_PP_GROUP_FAILOVER_THRESH, CBasePropertyPage::OnChangeCtrl)
  578. ON_EN_CHANGE(IDC_PP_GROUP_FAILOVER_PERIOD, CBasePropertyPage::OnChangeCtrl)
  579. END_MESSAGE_MAP()
  580. /////////////////////////////////////////////////////////////////////////////
  581. //++
  582. //
  583. // CGroupFailoverPage::CGroupFailoverPage
  584. //
  585. // Routine Description:
  586. // Constructor.
  587. //
  588. // Arguments:
  589. // None.
  590. //
  591. // Return Value:
  592. // None.
  593. //
  594. //--
  595. /////////////////////////////////////////////////////////////////////////////
  596. CGroupFailoverPage::CGroupFailoverPage(void)
  597. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_GROUP_FAILOVER)
  598. {
  599. //{{AFX_DATA_INIT(CGroupFailoverPage)
  600. // NOTE: the ClassWizard will add member initialization here
  601. //}}AFX_DATA_INIT
  602. } //*** CGroupFailoverPage::CGroupFailoverPage()
  603. /////////////////////////////////////////////////////////////////////////////
  604. //++
  605. //
  606. // CGroupFailoverPage::BInit
  607. //
  608. // Routine Description:
  609. // Initialize the page.
  610. //
  611. // Arguments:
  612. // psht [IN OUT] Property sheet to which this page belongs.
  613. //
  614. // Return Value:
  615. // TRUE Page initialized successfully.
  616. // FALSE Page failed to initialize.
  617. //
  618. //--
  619. /////////////////////////////////////////////////////////////////////////////
  620. BOOL CGroupFailoverPage::BInit(IN OUT CBaseSheet * psht)
  621. {
  622. BOOL fSuccess;
  623. ASSERT_KINDOF(CGroupPropSheet, psht);
  624. fSuccess = CBasePropertyPage::BInit(psht);
  625. m_nThreshold= PciGroup()->NFailoverThreshold();
  626. m_nPeriod= PciGroup()->NFailoverPeriod();
  627. return fSuccess;
  628. } //*** CBasePropertyPage::BInit()
  629. /////////////////////////////////////////////////////////////////////////////
  630. //++
  631. //
  632. // CGroupFailoverPage::DoDataExchange
  633. //
  634. // Routine Description:
  635. // Do data exchange between the dialog and the class.
  636. //
  637. // Arguments:
  638. // pDX [IN OUT] Data exchange object
  639. //
  640. // Return Value:
  641. // None.
  642. //
  643. //--
  644. /////////////////////////////////////////////////////////////////////////////
  645. void CGroupFailoverPage::DoDataExchange(CDataExchange* pDX)
  646. {
  647. CBasePropertyPage::DoDataExchange(pDX);
  648. //{{AFX_DATA_MAP(CGroupFailoverPage)
  649. DDX_Control(pDX, IDC_PP_GROUP_FAILOVER_THRESH, m_editThreshold);
  650. DDX_Control(pDX, IDC_PP_GROUP_FAILOVER_PERIOD, m_editPeriod);
  651. //}}AFX_DATA_MAP
  652. if (pDX->m_bSaveAndValidate)
  653. {
  654. if (!BReadOnly())
  655. {
  656. DDX_Number(
  657. pDX,
  658. IDC_PP_GROUP_FAILOVER_THRESH,
  659. m_nThreshold,
  660. CLUSTER_GROUP_MINIMUM_FAILOVER_THRESHOLD,
  661. CLUSTER_GROUP_MAXIMUM_FAILOVER_THRESHOLD
  662. );
  663. DDX_Number(
  664. pDX,
  665. IDC_PP_GROUP_FAILOVER_PERIOD,
  666. m_nPeriod,
  667. CLUSTER_GROUP_MINIMUM_FAILOVER_PERIOD,
  668. CLUSTER_GROUP_MAXIMUM_FAILOVER_PERIOD
  669. );
  670. try
  671. {
  672. PciGroup()->ValidateCommonProperties(
  673. PciGroup()->StrDescription(),
  674. m_nThreshold,
  675. m_nPeriod,
  676. PciGroup()->CgaftAutoFailbackType(),
  677. PciGroup()->NFailbackWindowStart(),
  678. PciGroup()->NFailbackWindowEnd()
  679. );
  680. } // try
  681. catch (CException * pe)
  682. {
  683. pe->ReportError();
  684. pe->Delete();
  685. pDX->Fail();
  686. } // catch: CException
  687. } // if: not read only
  688. } // if: saving data from dialog
  689. else
  690. {
  691. DDX_Number(
  692. pDX,
  693. IDC_PP_GROUP_FAILOVER_THRESH,
  694. m_nThreshold,
  695. CLUSTER_GROUP_MINIMUM_FAILOVER_THRESHOLD,
  696. CLUSTER_GROUP_MAXIMUM_FAILOVER_THRESHOLD
  697. );
  698. DDX_Number(
  699. pDX,
  700. IDC_PP_GROUP_FAILOVER_PERIOD,
  701. m_nPeriod,
  702. CLUSTER_GROUP_MINIMUM_FAILOVER_PERIOD,
  703. CLUSTER_GROUP_MAXIMUM_FAILOVER_PERIOD
  704. );
  705. } // else: setting data to dialog
  706. } //*** CGroupFailoverPage::DoDataExchange()
  707. /////////////////////////////////////////////////////////////////////////////
  708. //++
  709. //
  710. // CGroupFailoverPage::OnInitDialog
  711. //
  712. // Routine Description:
  713. // Handler for the WM_INITDIALOG message.
  714. //
  715. // Arguments:
  716. // None.
  717. //
  718. // Return Value:
  719. // TRUE Focus needs to be set.
  720. // FALSE Focus already set.
  721. //
  722. //--
  723. /////////////////////////////////////////////////////////////////////////////
  724. BOOL CGroupFailoverPage::OnInitDialog(void)
  725. {
  726. CBasePropertyPage::OnInitDialog();
  727. // If read-only, set all controls to be either disabled or read-only.
  728. if (BReadOnly())
  729. {
  730. m_editPeriod.SetReadOnly(TRUE);
  731. m_editThreshold.SetReadOnly(TRUE);
  732. } // if: sheet is read-only
  733. return TRUE; // return TRUE unless you set the focus to a control
  734. // EXCEPTION: OCX Property Pages should return FALSE
  735. } //*** CGroupFailoverPage::OnInitDialog()
  736. /////////////////////////////////////////////////////////////////////////////
  737. //++
  738. //
  739. // CGroupFailoverPage::OnApply
  740. //
  741. // Routine Description:
  742. // Handler for when the Apply button is pressed.
  743. //
  744. // Arguments:
  745. // None.
  746. //
  747. // Return Value:
  748. // TRUE Page successfully applied.
  749. // FALSE Error applying page.
  750. //
  751. //--
  752. /////////////////////////////////////////////////////////////////////////////
  753. BOOL CGroupFailoverPage::OnApply(void)
  754. {
  755. // Set the data from the page in the cluster item.
  756. try
  757. {
  758. CWaitCursor wc;
  759. PciGroup()->SetCommonProperties(
  760. PciGroup()->StrDescription(),
  761. m_nThreshold,
  762. m_nPeriod,
  763. PciGroup()->CgaftAutoFailbackType(),
  764. PciGroup()->NFailbackWindowStart(),
  765. PciGroup()->NFailbackWindowEnd()
  766. );
  767. } // try
  768. catch (CException * pe)
  769. {
  770. pe->ReportError();
  771. pe->Delete();
  772. return FALSE;
  773. } // catch: CException
  774. return CBasePropertyPage::OnApply();
  775. } //*** CGroupFailoverPage::OnApply()
  776. //*************************************************************************//
  777. /////////////////////////////////////////////////////////////////////////////
  778. // CGroupFailbackPage property page
  779. /////////////////////////////////////////////////////////////////////////////
  780. IMPLEMENT_DYNCREATE(CGroupFailbackPage, CBasePropertyPage)
  781. /////////////////////////////////////////////////////////////////////////////
  782. // Message Maps
  783. /////////////////////////////////////////////////////////////////////////////
  784. BEGIN_MESSAGE_MAP(CGroupFailbackPage, CBasePropertyPage)
  785. //{{AFX_MSG_MAP(CGroupFailbackPage)
  786. ON_BN_CLICKED(IDC_PP_GROUP_AUTOFB_PREVENT, OnClickedPreventFailback)
  787. ON_BN_CLICKED(IDC_PP_GROUP_AUTOFB_ALLOW, OnClickedAllowFailback)
  788. ON_BN_CLICKED(IDC_PP_GROUP_FB_IMMED, OnClickedFailbackImmediate)
  789. ON_BN_CLICKED(IDC_PP_GROUP_FB_WINDOW, OnClickedFailbackInWindow)
  790. //}}AFX_MSG_MAP
  791. ON_EN_CHANGE(IDC_PP_GROUP_FBWIN_START, CBasePropertyPage::OnChangeCtrl)
  792. ON_EN_CHANGE(IDC_PP_GROUP_FBWIN_END, CBasePropertyPage::OnChangeCtrl)
  793. END_MESSAGE_MAP()
  794. /////////////////////////////////////////////////////////////////////////////
  795. //++
  796. //
  797. // CGroupFailbackPage::CGroupFailbackPage
  798. //
  799. // Routine Description:
  800. // Constructor.
  801. //
  802. // Arguments:
  803. // None.
  804. //
  805. // Return Value:
  806. // None.
  807. //
  808. //--
  809. /////////////////////////////////////////////////////////////////////////////
  810. CGroupFailbackPage::CGroupFailbackPage(void)
  811. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_GROUP_FAILBACK)
  812. {
  813. //{{AFX_DATA_INIT(CGroupFailbackPage)
  814. //}}AFX_DATA_INIT
  815. m_nStart = CLUSTER_GROUP_FAILBACK_WINDOW_NONE;
  816. m_nEnd = CLUSTER_GROUP_FAILBACK_WINDOW_NONE;
  817. } //*** CGroupFailbackPage::CGroupFailbackPage()
  818. /////////////////////////////////////////////////////////////////////////////
  819. //++
  820. //
  821. // CGroupFailbackPage::BInit
  822. //
  823. // Routine Description:
  824. // Initialize the page.
  825. //
  826. // Arguments:
  827. // psht [IN OUT] Property sheet to which this page belongs.
  828. //
  829. // Return Value:
  830. // TRUE Page initialized successfully.
  831. // FALSE Page failed to initialize.
  832. //
  833. //--
  834. /////////////////////////////////////////////////////////////////////////////
  835. BOOL CGroupFailbackPage::BInit(IN OUT CBaseSheet * psht)
  836. {
  837. BOOL bSuccess;
  838. ASSERT_KINDOF(CGroupPropSheet, psht);
  839. bSuccess = CBasePropertyPage::BInit(psht);
  840. m_cgaft = PciGroup()->CgaftAutoFailbackType();
  841. m_nStart = PciGroup()->NFailbackWindowStart();
  842. m_nEnd = PciGroup()->NFailbackWindowEnd();
  843. m_bNoFailbackWindow = ((m_cgaft == ClusterGroupPreventFailback)
  844. || (m_nStart == CLUSTER_GROUP_FAILBACK_WINDOW_NONE)
  845. || (m_nEnd == CLUSTER_GROUP_FAILBACK_WINDOW_NONE));
  846. return bSuccess;
  847. } //*** CGroupFailbackPage::BInit()
  848. /////////////////////////////////////////////////////////////////////////////
  849. //++
  850. //
  851. // CGroupFailbackPage::DoDataExchange
  852. //
  853. // Routine Description:
  854. // Do data exchange between the dialog and the class.
  855. //
  856. // Arguments:
  857. // pDX [IN OUT] Data exchange object
  858. //
  859. // Return Value:
  860. // None.
  861. //
  862. //--
  863. /////////////////////////////////////////////////////////////////////////////
  864. void CGroupFailbackPage::DoDataExchange(CDataExchange * pDX)
  865. {
  866. CBasePropertyPage::DoDataExchange(pDX);
  867. //{{AFX_DATA_MAP(CGroupFailbackPage)
  868. DDX_Control(pDX, IDC_PP_GROUP_AUTOFB_PREVENT, m_rbPreventFailback);
  869. DDX_Control(pDX, IDC_PP_GROUP_AUTOFB_ALLOW, m_rbAllowFailback);
  870. DDX_Control(pDX, IDC_PP_GROUP_FB_IMMED, m_rbFBImmed);
  871. DDX_Control(pDX, IDC_PP_GROUP_FB_WINDOW, m_rbFBWindow);
  872. DDX_Control(pDX, IDC_PP_GROUP_FB_WINDOW_LABEL1, m_staticFBWindow1);
  873. DDX_Control(pDX, IDC_PP_GROUP_FB_WINDOW_LABEL2, m_staticFBWindow2);
  874. DDX_Control(pDX, IDC_PP_GROUP_FBWIN_START, m_editStart);
  875. DDX_Control(pDX, IDC_PP_GROUP_FBWIN_START_SPIN, m_spinStart);
  876. DDX_Control(pDX, IDC_PP_GROUP_FBWIN_END, m_editEnd);
  877. DDX_Control(pDX, IDC_PP_GROUP_FBWIN_END_SPIN, m_spinEnd);
  878. //}}AFX_DATA_MAP
  879. if (pDX->m_bSaveAndValidate)
  880. {
  881. if (!BReadOnly())
  882. {
  883. if ((m_cgaft == ClusterGroupAllowFailback) && !m_bNoFailbackWindow)
  884. {
  885. DDX_Number(pDX, IDC_PP_GROUP_FBWIN_START, m_nStart, 0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_START);
  886. DDX_Number(pDX, IDC_PP_GROUP_FBWIN_END, m_nEnd, 0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_END);
  887. if (m_nStart == m_nEnd)
  888. {
  889. AfxMessageBox(IDS_SAME_START_AND_END, MB_OK | MB_ICONEXCLAMATION);
  890. pDX->Fail();
  891. } // if: values are the same
  892. } // if: failback is allowed and failback window desired
  893. try
  894. {
  895. PciGroup()->ValidateCommonProperties(
  896. PciGroup()->StrDescription(),
  897. PciGroup()->NFailoverThreshold(),
  898. PciGroup()->NFailoverPeriod(),
  899. m_cgaft,
  900. m_nStart,
  901. m_nEnd
  902. );
  903. } // try
  904. catch (CException * pe)
  905. {
  906. pe->ReportError();
  907. pe->Delete();
  908. pDX->Fail();
  909. } // catch: CException
  910. } // if: not read only
  911. } // if: saving data
  912. else
  913. {
  914. if (m_cgaft == ClusterGroupPreventFailback)
  915. {
  916. m_rbPreventFailback.SetCheck(BST_CHECKED);
  917. m_rbAllowFailback.SetCheck(BST_UNCHECKED);
  918. OnClickedPreventFailback();
  919. } // if: failbacks are not allowed
  920. else
  921. {
  922. m_rbPreventFailback.SetCheck(BST_UNCHECKED);
  923. m_rbAllowFailback.SetCheck(BST_CHECKED);
  924. OnClickedAllowFailback();
  925. } // else: failbacks are allowed
  926. m_rbFBImmed.SetCheck(m_bNoFailbackWindow ? BST_CHECKED : BST_UNCHECKED);
  927. m_rbFBWindow.SetCheck(m_bNoFailbackWindow ? BST_UNCHECKED : BST_CHECKED);
  928. // Set up the Start and End window controls.
  929. DDX_Number(pDX, IDC_PP_GROUP_FBWIN_START, m_nStart, 0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_START);
  930. DDX_Number(pDX, IDC_PP_GROUP_FBWIN_END, m_nEnd, 0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_END);
  931. m_spinStart.SetRange(0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_START);
  932. m_spinEnd.SetRange(0, CLUSTER_GROUP_MAXIMUM_FAILBACK_WINDOW_END);
  933. if (m_nStart == CLUSTER_GROUP_FAILBACK_WINDOW_NONE)
  934. {
  935. m_editStart.SetWindowText(TEXT(""));
  936. }
  937. if (m_nEnd == CLUSTER_GROUP_FAILBACK_WINDOW_NONE)
  938. {
  939. m_editEnd.SetWindowText(TEXT(""));
  940. }
  941. } // else: not saving data
  942. } //*** CGroupFailbackPage::DoDataExchange()
  943. /////////////////////////////////////////////////////////////////////////////
  944. //++
  945. //
  946. // CGroupFailbackPage::OnInitDialog
  947. //
  948. // Routine Description:
  949. // Handler for the WM_INITDIALOG message.
  950. //
  951. // Arguments:
  952. // None.
  953. //
  954. // Return Value:
  955. // TRUE Focus needs to be set.
  956. // FALSE Focus already set.
  957. //
  958. //--
  959. /////////////////////////////////////////////////////////////////////////////
  960. BOOL CGroupFailbackPage::OnInitDialog(void)
  961. {
  962. CBasePropertyPage::OnInitDialog();
  963. // If read-only, set all controls to be either disabled or read-only.
  964. if (BReadOnly())
  965. {
  966. m_rbPreventFailback.EnableWindow(FALSE);
  967. m_rbAllowFailback.EnableWindow(FALSE);
  968. m_rbFBImmed.EnableWindow(FALSE);
  969. m_rbFBWindow.EnableWindow(FALSE);
  970. m_staticFBWindow1.EnableWindow(FALSE);
  971. m_staticFBWindow2.EnableWindow(FALSE);
  972. m_spinStart.EnableWindow(FALSE);
  973. m_spinEnd.EnableWindow(FALSE);
  974. m_editStart.SetReadOnly(TRUE);
  975. m_editEnd.SetReadOnly(TRUE);
  976. } // if: sheet is read-only
  977. return TRUE; // return TRUE unless you set the focus to a control
  978. // EXCEPTION: OCX Property Pages should return FALSE
  979. } //*** CGroupFailbackPage::OnInitDialog()
  980. /////////////////////////////////////////////////////////////////////////////
  981. //++
  982. //
  983. // CGroupFailbackPage::OnApply
  984. //
  985. // Routine Description:
  986. // Handler for when the Apply button is pressed.
  987. //
  988. // Arguments:
  989. // None.
  990. //
  991. // Return Value:
  992. // TRUE Page successfully applied.
  993. // FALSE Error applying page.
  994. //
  995. //--
  996. /////////////////////////////////////////////////////////////////////////////
  997. BOOL CGroupFailbackPage::OnApply(void)
  998. {
  999. // Set the data from the page in the cluster item.
  1000. try
  1001. {
  1002. CWaitCursor wc;
  1003. if (m_bNoFailbackWindow)
  1004. {
  1005. m_nStart = CLUSTER_GROUP_FAILBACK_WINDOW_NONE;
  1006. m_nEnd = CLUSTER_GROUP_FAILBACK_WINDOW_NONE;
  1007. } // if: no failback window
  1008. PciGroup()->SetCommonProperties(
  1009. PciGroup()->StrDescription(),
  1010. PciGroup()->NFailoverThreshold(),
  1011. PciGroup()->NFailoverPeriod(),
  1012. m_cgaft,
  1013. m_nStart,
  1014. m_nEnd
  1015. );
  1016. } // try
  1017. catch (CException * pe)
  1018. {
  1019. pe->ReportError();
  1020. pe->Delete();
  1021. return FALSE;
  1022. } // catch: CException
  1023. return CBasePropertyPage::OnApply();
  1024. } //*** CGroupFailbackPage::OnApply()
  1025. /////////////////////////////////////////////////////////////////////////////
  1026. //++
  1027. //
  1028. // CGroupFailbackPage::OnClickedPreventFailback
  1029. //
  1030. // Routine Description:
  1031. // Handler for the BN_CLICKED message on the Prevent Failback radio button.
  1032. //
  1033. // Arguments:
  1034. // None.
  1035. //
  1036. // Return Value:
  1037. // None.
  1038. //
  1039. //--
  1040. /////////////////////////////////////////////////////////////////////////////
  1041. void CGroupFailbackPage::OnClickedPreventFailback(void)
  1042. {
  1043. // Disable the Failback Window controls.
  1044. m_rbFBImmed.EnableWindow(FALSE);
  1045. m_rbFBWindow.EnableWindow(FALSE);
  1046. m_staticFBWindow1.EnableWindow(FALSE);
  1047. m_staticFBWindow2.EnableWindow(FALSE);
  1048. OnClickedFailbackImmediate();
  1049. // Call the base class method if the state changed.
  1050. if (m_cgaft != ClusterGroupPreventFailback)
  1051. {
  1052. CBasePropertyPage::OnChangeCtrl();
  1053. m_cgaft = ClusterGroupPreventFailback;
  1054. } // if: state changed
  1055. } //*** CGroupFailbackPage::OnClickedPreventFailback()
  1056. /////////////////////////////////////////////////////////////////////////////
  1057. //++
  1058. //
  1059. // CGroupFailbackPage::OnClickedAllowFailback
  1060. //
  1061. // Routine Description:
  1062. // Handler for the BN_CLICKED message on the Allow Failback radio button.
  1063. //
  1064. // Arguments:
  1065. // None.
  1066. //
  1067. // Return Value:
  1068. // None.
  1069. //
  1070. //--
  1071. /////////////////////////////////////////////////////////////////////////////
  1072. void CGroupFailbackPage::OnClickedAllowFailback(void)
  1073. {
  1074. // Enable the Failback Window controls.
  1075. m_rbFBImmed.EnableWindow(TRUE);
  1076. m_rbFBWindow.EnableWindow(TRUE);
  1077. m_staticFBWindow1.EnableWindow(TRUE);
  1078. m_staticFBWindow2.EnableWindow(TRUE);
  1079. if (m_bNoFailbackWindow)
  1080. {
  1081. OnClickedFailbackImmediate();
  1082. }
  1083. else
  1084. {
  1085. OnClickedFailbackInWindow();
  1086. }
  1087. // Call the base class method if the state changed.
  1088. if (m_cgaft != ClusterGroupAllowFailback)
  1089. {
  1090. CBasePropertyPage::OnChangeCtrl();
  1091. m_cgaft = ClusterGroupAllowFailback;
  1092. } // if: state changed
  1093. } //*** CGroupFailbackPage::OnClickedAllowFailback()
  1094. /////////////////////////////////////////////////////////////////////////////
  1095. //++
  1096. //
  1097. // CGroupFailbackPage::OnClickedFailbackImmediate
  1098. //
  1099. // Routine Description:
  1100. // Handler for the BN_CLICKED message on the Failback Immediately radio button.
  1101. //
  1102. // Arguments:
  1103. // None.
  1104. //
  1105. // Return Value:
  1106. // None.
  1107. //
  1108. //--
  1109. /////////////////////////////////////////////////////////////////////////////
  1110. void CGroupFailbackPage::OnClickedFailbackImmediate(void)
  1111. {
  1112. // Disable the Failback Window controls.
  1113. m_editStart.EnableWindow(FALSE);
  1114. m_spinStart.EnableWindow(FALSE);
  1115. m_editEnd.EnableWindow(FALSE);
  1116. m_spinEnd.EnableWindow(FALSE);
  1117. // Call the base class method if the state changed.
  1118. if (!m_bNoFailbackWindow)
  1119. {
  1120. CBasePropertyPage::OnChangeCtrl();
  1121. }
  1122. m_bNoFailbackWindow = TRUE;
  1123. } //*** CGroupFailbackPage::OnClickedFailbackImmediate()
  1124. /////////////////////////////////////////////////////////////////////////////
  1125. //++
  1126. //
  1127. // CGroupFailbackPage::OnClickedFailbackInWindow
  1128. //
  1129. // Routine Description:
  1130. // Handler for the BN_CLICKED message on the Failback In Window radio button.
  1131. //
  1132. // Arguments:
  1133. // None.
  1134. //
  1135. // Return Value:
  1136. // None.
  1137. //
  1138. //--
  1139. /////////////////////////////////////////////////////////////////////////////
  1140. void CGroupFailbackPage::OnClickedFailbackInWindow(void)
  1141. {
  1142. // Enable the Failback Window controls.
  1143. m_editStart.EnableWindow(TRUE);
  1144. m_spinStart.EnableWindow(TRUE);
  1145. m_editEnd.EnableWindow(TRUE);
  1146. m_spinEnd.EnableWindow(TRUE);
  1147. if (m_bNoFailbackWindow)
  1148. {
  1149. // Set the values of the edit controls.
  1150. if (m_nStart == CLUSTER_GROUP_FAILBACK_WINDOW_NONE)
  1151. {
  1152. SetDlgItemInt(IDC_PP_GROUP_FBWIN_START, 0, FALSE);
  1153. }
  1154. if (m_nEnd == CLUSTER_GROUP_FAILBACK_WINDOW_NONE)
  1155. {
  1156. SetDlgItemInt(IDC_PP_GROUP_FBWIN_END, 0, FALSE);
  1157. }
  1158. // Call the base class method.
  1159. CBasePropertyPage::OnChangeCtrl();
  1160. } // if: state changed
  1161. m_bNoFailbackWindow = FALSE;
  1162. } //*** CGroupFailbackPage::OnClickedFailbackInWindow()