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.

1282 lines
33 KiB

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