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.

2134 lines
66 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ResProp.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the resource property sheet and pages.
  10. //
  11. // Author:
  12. // David Potter (davidp) May 16, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "CluAdmin.h"
  21. #include "ConstDef.h"
  22. #include "ResProp.h"
  23. #include "Res.h"
  24. #include "ClusDoc.h"
  25. #include "Cluster.h"
  26. #include "ModNodes.h"
  27. #include "ModRes.h"
  28. #include "DDxDDv.h"
  29. #include "HelpData.h"
  30. #include "ExcOper.h"
  31. #include "resource.h"
  32. #ifdef _DEBUG
  33. #define new DEBUG_NEW
  34. #undef THIS_FILE
  35. static char THIS_FILE[] = __FILE__;
  36. #endif
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CResourcePropSheet
  39. /////////////////////////////////////////////////////////////////////////////
  40. IMPLEMENT_DYNAMIC(CResourcePropSheet, CBasePropertySheet)
  41. /////////////////////////////////////////////////////////////////////////////
  42. // Message Maps
  43. BEGIN_MESSAGE_MAP(CResourcePropSheet, CBasePropertySheet)
  44. //{{AFX_MSG_MAP(CResourcePropSheet)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. //++
  49. //
  50. // CResourcePropSheet::CResourcePropSheet
  51. //
  52. // Routine Description:
  53. // Constructor.
  54. //
  55. // Arguments:
  56. // pParentWnd [IN OUT] Parent window for this property sheet.
  57. // iSelectPage [IN] Page to show first.
  58. //
  59. // Return Value:
  60. // None.
  61. //
  62. //--
  63. /////////////////////////////////////////////////////////////////////////////
  64. CResourcePropSheet::CResourcePropSheet(
  65. IN OUT CWnd * pParentWnd,
  66. IN UINT iSelectPage
  67. )
  68. : CBasePropertySheet(pParentWnd, iSelectPage)
  69. {
  70. m_rgpages[0] = &PageGeneral();
  71. m_rgpages[1] = &PageDepends();
  72. m_rgpages[2] = &PageAdvanced();
  73. } //*** CResourcePropSheet::CResourcePropSheet()
  74. /////////////////////////////////////////////////////////////////////////////
  75. //++
  76. //
  77. // CResourcePropSheet::BInit
  78. //
  79. // Routine Description:
  80. // Initialize the property sheet.
  81. //
  82. // Arguments:
  83. // pci [IN OUT] Cluster item whose properties are to be displayed.
  84. // iimgIcon [IN] Index in the large image list for the image to use
  85. // as the icon on each page.
  86. //
  87. // Return Value:
  88. // TRUE Property sheet initialized successfully.
  89. // FALSE Error initializing property sheet.
  90. //
  91. //--
  92. /////////////////////////////////////////////////////////////////////////////
  93. BOOL CResourcePropSheet::BInit(
  94. IN OUT CClusterItem * pci,
  95. IN IIMG iimgIcon
  96. )
  97. {
  98. // Call the base class method.
  99. if (!CBasePropertySheet::BInit(pci, iimgIcon))
  100. return FALSE;
  101. // Set the read-only flag if the handles are invalid.
  102. m_bReadOnly = PciRes()->BReadOnly()
  103. || (PciRes()->Crs() == ClusterResourceStateUnknown);
  104. SetPfGetResNetName(CResourceDependsPage::BGetNetworkName, &PageDepends());
  105. return TRUE;
  106. } //*** CResourcePropSheet::BInit()
  107. /////////////////////////////////////////////////////////////////////////////
  108. //++
  109. //
  110. // CResourcePropSheet::Ppages
  111. //
  112. // Routine Description:
  113. // Returns the array of pages to add to the property sheet.
  114. //
  115. // Arguments:
  116. // None.
  117. //
  118. // Return Value:
  119. // Page array.
  120. //
  121. //--
  122. /////////////////////////////////////////////////////////////////////////////
  123. CBasePropertyPage ** CResourcePropSheet::Ppages(void)
  124. {
  125. return m_rgpages;
  126. } //*** CResourcePropSheet::Pppges()
  127. /////////////////////////////////////////////////////////////////////////////
  128. //++
  129. //
  130. // CResourcePropSheet::Cpages
  131. //
  132. // Routine Description:
  133. // Returns the count of pages in the array.
  134. //
  135. // Arguments:
  136. // None.
  137. //
  138. // Return Value:
  139. // Count of pages in the array.
  140. //
  141. //--
  142. /////////////////////////////////////////////////////////////////////////////
  143. int CResourcePropSheet::Cpages(void)
  144. {
  145. return sizeof(m_rgpages) / sizeof(CBasePropertyPage *);
  146. } //*** CResourcePropSheet::Cpages()
  147. //*************************************************************************//
  148. /////////////////////////////////////////////////////////////////////////////
  149. // CResourceGeneralPage property page
  150. /////////////////////////////////////////////////////////////////////////////
  151. IMPLEMENT_DYNCREATE(CResourceGeneralPage, CBasePropertyPage)
  152. /////////////////////////////////////////////////////////////////////////////
  153. // Message Maps
  154. BEGIN_MESSAGE_MAP(CResourceGeneralPage, CBasePropertyPage)
  155. //{{AFX_MSG_MAP(CResourceGeneralPage)
  156. ON_BN_CLICKED(IDC_PP_RES_POSSIBLE_OWNERS_MODIFY, OnModifyPossibleOwners)
  157. ON_LBN_DBLCLK(IDC_PP_RES_POSSIBLE_OWNERS, OnDblClkPossibleOwners)
  158. ON_WM_CONTEXTMENU()
  159. //}}AFX_MSG_MAP
  160. ON_EN_CHANGE(IDC_PP_RES_NAME, CBasePropertyPage::OnChangeCtrl)
  161. ON_EN_CHANGE(IDC_PP_RES_DESC, CBasePropertyPage::OnChangeCtrl)
  162. ON_BN_CLICKED(IDC_PP_RES_SEPARATE_MONITOR, CBasePropertyPage::OnChangeCtrl)
  163. ON_COMMAND(ID_FILE_PROPERTIES, OnProperties)
  164. END_MESSAGE_MAP()
  165. /////////////////////////////////////////////////////////////////////////////
  166. //++
  167. //
  168. // CResourceGeneralPage::CResourceGeneralPage
  169. //
  170. // Routine Description:
  171. // Constructor.
  172. //
  173. // Arguments:
  174. // None.
  175. //
  176. // Return Value:
  177. // None.
  178. //
  179. //--
  180. /////////////////////////////////////////////////////////////////////////////
  181. CResourceGeneralPage::CResourceGeneralPage(void)
  182. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_RES_GENERAL)
  183. {
  184. //{{AFX_DATA_INIT(CResourceGeneralPage)
  185. m_strName = _T("");
  186. m_strDesc = _T("");
  187. m_strGroup = _T("");
  188. m_strState = _T("");
  189. m_strNode = _T("");
  190. m_bSeparateMonitor = FALSE;
  191. //}}AFX_DATA_INIT
  192. } //*** CResourceGeneralPage::CResourceGeneralPage()
  193. /////////////////////////////////////////////////////////////////////////////
  194. //++
  195. //
  196. // CResourceGeneralPage::BInit
  197. //
  198. // Routine Description:
  199. // Initialize the page.
  200. //
  201. // Arguments:
  202. // psht [IN OUT] Property sheet to which this page belongs.
  203. //
  204. // Return Value:
  205. // TRUE Page initialized successfully.
  206. // FALSE Page failed to initialize.
  207. //
  208. //--
  209. /////////////////////////////////////////////////////////////////////////////
  210. BOOL CResourceGeneralPage::BInit(IN OUT CBaseSheet * psht)
  211. {
  212. BOOL bSuccess;
  213. ASSERT_KINDOF(CResourcePropSheet, psht);
  214. bSuccess = CBasePropertyPage::BInit(psht);
  215. if (bSuccess)
  216. {
  217. try
  218. {
  219. m_strName = PciRes()->StrName();
  220. m_strDesc = PciRes()->StrDescription();
  221. if (PciRes()->PciResourceType() != NULL)
  222. m_strType = PciRes()->PciResourceType()->StrDisplayName();
  223. m_strGroup = PciRes()->StrGroup();
  224. m_strNode = PciRes()->StrOwner();
  225. m_bSeparateMonitor = PciRes()->BSeparateMonitor();
  226. // Duplicate the possible owners list.
  227. {
  228. POSITION pos;
  229. CClusterNode * pciNode;
  230. pos = PciRes()->LpcinodePossibleOwners().GetHeadPosition();
  231. while (pos != NULL)
  232. {
  233. pciNode = (CClusterNode *) PciRes()->LpcinodePossibleOwners().GetNext(pos);
  234. ASSERT_VALID(pciNode);
  235. m_lpciPossibleOwners.AddTail(pciNode);
  236. } // while: more nodes in the list
  237. } // Duplicate the possible owners list
  238. PciRes()->GetStateName(m_strState);
  239. } // try
  240. catch (CException * pe)
  241. {
  242. pe->ReportError();
  243. pe->Delete();
  244. bSuccess = FALSE;
  245. } // catch: CException
  246. } // if: base class method was successful
  247. return bSuccess;
  248. } //*** CResourceGeneralPage::BInit()
  249. /////////////////////////////////////////////////////////////////////////////
  250. //++
  251. //
  252. // CResourceGeneralPage::DoDataExchange
  253. //
  254. // Routine Description:
  255. // Do data exchange between the dialog and the class.
  256. //
  257. // Arguments:
  258. // pDX [IN OUT] Data exchange object
  259. //
  260. // Return Value:
  261. // None.
  262. //
  263. //--
  264. /////////////////////////////////////////////////////////////////////////////
  265. void CResourceGeneralPage::DoDataExchange(CDataExchange * pDX)
  266. {
  267. CBasePropertyPage::DoDataExchange(pDX);
  268. //{{AFX_DATA_MAP(CResourceGeneralPage)
  269. DDX_Control(pDX, IDC_PP_RES_DESC, m_editDesc);
  270. DDX_Control(pDX, IDC_PP_RES_SEPARATE_MONITOR, m_ckbSeparateMonitor);
  271. DDX_Control(pDX, IDC_PP_RES_POSSIBLE_OWNERS_MODIFY, m_pbPossibleOwnersModify);
  272. DDX_Control(pDX, IDC_PP_RES_POSSIBLE_OWNERS, m_lbPossibleOwners);
  273. DDX_Control(pDX, IDC_PP_RES_NAME, m_editName);
  274. DDX_Text(pDX, IDC_PP_RES_NAME, m_strName);
  275. DDX_Text(pDX, IDC_PP_RES_DESC, m_strDesc);
  276. DDX_Text(pDX, IDC_PP_RES_RESOURCE_TYPE, m_strType);
  277. DDX_Text(pDX, IDC_PP_RES_GROUP, m_strGroup);
  278. DDX_Text(pDX, IDC_PP_RES_CURRENT_STATE, m_strState);
  279. DDX_Text(pDX, IDC_PP_RES_CURRENT_NODE, m_strNode);
  280. DDX_Check(pDX, IDC_PP_RES_SEPARATE_MONITOR, m_bSeparateMonitor);
  281. //}}AFX_DATA_MAP
  282. if (pDX->m_bSaveAndValidate)
  283. {
  284. if (!BReadOnly())
  285. {
  286. DDV_RequiredText(pDX, IDC_PP_RES_NAME, IDC_PP_RES_NAME_LABEL, m_strName);
  287. try
  288. {
  289. PciRes()->ValidateCommonProperties(
  290. m_strDesc,
  291. m_bSeparateMonitor,
  292. PciRes()->NLooksAlive(),
  293. PciRes()->NIsAlive(),
  294. PciRes()->CrraRestartAction(),
  295. PciRes()->NRestartThreshold(),
  296. PciRes()->NRestartPeriod(),
  297. PciRes()->NPendingTimeout()
  298. );
  299. } // try
  300. catch (CException * pe)
  301. {
  302. pe->ReportError();
  303. pe->Delete();
  304. pDX->Fail();
  305. } // catch: CException
  306. if ((LpciPossibleOwners().GetCount() == 0))
  307. {
  308. ID id = AfxMessageBox(IDS_NO_POSSIBLE_OWNERS_QUERY, MB_YESNO | MB_ICONWARNING);
  309. if (id == IDNO)
  310. pDX->Fail();
  311. } // if: no possible owners
  312. } // if: not read only
  313. } // if: saving data from the dialog
  314. else
  315. {
  316. FillPossibleOwners();
  317. } // else: setting data to the dialog
  318. } //*** CResourceGeneralPage::DoDataExchange()
  319. /////////////////////////////////////////////////////////////////////////////
  320. //++
  321. //
  322. // CResourceGeneralPage::FillPossibleOwners
  323. //
  324. // Routine Description:
  325. // Fill the Possible Owners list box.
  326. //
  327. // Arguments:
  328. // None.
  329. //
  330. // Return Value:
  331. // None.
  332. //
  333. //--
  334. /////////////////////////////////////////////////////////////////////////////
  335. void CResourceGeneralPage::FillPossibleOwners(void)
  336. {
  337. POSITION posPci;
  338. CClusterNode * pciNode;
  339. int iitem;
  340. m_lbPossibleOwners.ResetContent();
  341. posPci = LpciPossibleOwners().GetHeadPosition();
  342. while (posPci != NULL)
  343. {
  344. pciNode = (CClusterNode *) LpciPossibleOwners().GetNext(posPci);
  345. iitem = m_lbPossibleOwners.AddString(pciNode->StrName());
  346. if (iitem >= 0)
  347. m_lbPossibleOwners.SetItemDataPtr(iitem, pciNode);
  348. } // for: each string in the list
  349. } //*** CResourceGeneralPage::FillPossibleOwners()
  350. /////////////////////////////////////////////////////////////////////////////
  351. //++
  352. //
  353. // CResourceGeneralPage::OnInitDialog
  354. //
  355. // Routine Description:
  356. // Handler for the WM_INITDIALOG message.
  357. //
  358. // Arguments:
  359. // None.
  360. //
  361. // Return Value:
  362. // TRUE Focus needs to be set.
  363. // FALSE Focus already set.
  364. //
  365. //--
  366. /////////////////////////////////////////////////////////////////////////////
  367. BOOL CResourceGeneralPage::OnInitDialog(void)
  368. {
  369. CBasePropertyPage::OnInitDialog();
  370. // If read-only, set all controls to be either disabled or read-only.
  371. if (BReadOnly())
  372. {
  373. m_editName.SetReadOnly(TRUE);
  374. m_editDesc.SetReadOnly(TRUE);
  375. m_pbPossibleOwnersModify.EnableWindow(FALSE);
  376. m_ckbSeparateMonitor.EnableWindow(FALSE);
  377. } // if: sheet is read-only
  378. return TRUE; // return TRUE unless you set the focus to a control
  379. // EXCEPTION: OCX Property Pages should return FALSE
  380. } //*** CResourceGeneralPage::OnInitDialog()
  381. /////////////////////////////////////////////////////////////////////////////
  382. //++
  383. //
  384. // CResourceGeneralPage::OnApply
  385. //
  386. // Routine Description:
  387. // Handler for when the Apply button is pressed.
  388. //
  389. // Arguments:
  390. // None.
  391. //
  392. // Return Value:
  393. // TRUE Page successfully applied.
  394. // FALSE Error applying page.
  395. //
  396. //--
  397. /////////////////////////////////////////////////////////////////////////////
  398. BOOL CResourceGeneralPage::OnApply(void)
  399. {
  400. // Set the data from the page in the cluster item.
  401. try
  402. {
  403. CWaitCursor wc;
  404. PciRes()->SetName(m_strName);
  405. PciRes()->SetPossibleOwners(LpciPossibleOwners());
  406. PciRes()->SetCommonProperties(
  407. m_strDesc,
  408. m_bSeparateMonitor,
  409. PciRes()->NLooksAlive(),
  410. PciRes()->NIsAlive(),
  411. PciRes()->CrraRestartAction(),
  412. PciRes()->NRestartThreshold(),
  413. PciRes()->NRestartPeriod(),
  414. PciRes()->NPendingTimeout()
  415. );
  416. } // try
  417. catch (CNTException * pnte)
  418. {
  419. pnte->ReportError();
  420. pnte->Delete();
  421. if (pnte->Sc() != ERROR_RESOURCE_PROPERTIES_STORED)
  422. return FALSE;
  423. } // catch: CNTException
  424. catch (CException * pe)
  425. {
  426. pe->ReportError();
  427. pe->Delete();
  428. return FALSE;
  429. } // catch: CException
  430. return CBasePropertyPage::OnApply();
  431. } //*** CResourceGeneralPage::OnApply()
  432. /////////////////////////////////////////////////////////////////////////////
  433. //++
  434. //
  435. // CResourceGeneralPage::OnProperties
  436. //
  437. // Routine Description:
  438. // Handler for the BN_CLICKED message on the Properties button.
  439. //
  440. // Arguments:
  441. // None.
  442. //
  443. // Return Value:
  444. // None.
  445. //
  446. //--
  447. /////////////////////////////////////////////////////////////////////////////
  448. void CResourceGeneralPage::OnProperties(void)
  449. {
  450. int iitem;
  451. CClusterNode * pciNode;
  452. // Get the item with the focus.
  453. iitem = m_lbPossibleOwners.GetCurSel();
  454. ASSERT(iitem >= 0);
  455. if (iitem >= 0)
  456. {
  457. // Get the node pointer.
  458. pciNode = (CClusterNode *) m_lbPossibleOwners.GetItemDataPtr(iitem);
  459. ASSERT_VALID(pciNode);
  460. // Set properties of that item.
  461. if (pciNode->BDisplayProperties())
  462. {
  463. } // if: properties changed
  464. } // if: found an item with focus
  465. } //*** CResourceGeneralPage::OnProperties()
  466. /////////////////////////////////////////////////////////////////////////////
  467. //++
  468. //
  469. // CResourceGeneralPage::OnContextMenu
  470. //
  471. // Routine Description:
  472. // Handler for the WM_CONTEXTMENU method.
  473. //
  474. // Arguments:
  475. // pWnd Window in which the user right clicked the mouse.
  476. // point Position of the cursor, in screen coordinates.
  477. //
  478. // Return Value:
  479. // None.
  480. //
  481. //--
  482. /////////////////////////////////////////////////////////////////////////////
  483. void CResourceGeneralPage::OnContextMenu(CWnd * pWnd, CPoint point)
  484. {
  485. BOOL bHandled = FALSE;
  486. CMenu * pmenu = NULL;
  487. CListBox * pListBox = (CListBox *) pWnd;
  488. CString strMenuName;
  489. CWaitCursor wc;
  490. // If focus is not in the list control, don't handle the message.
  491. if ( pWnd == &m_lbPossibleOwners )
  492. {
  493. // Create the menu to display.
  494. try
  495. {
  496. pmenu = new CMenu;
  497. if ( pmenu == NULL )
  498. {
  499. AfxThrowMemoryException();
  500. } // if: error allocating the menu
  501. if ( pmenu->CreatePopupMenu() )
  502. {
  503. UINT nFlags = MF_STRING;
  504. // If there are no items in the list, disable the menu item.
  505. if ( pListBox->GetCount() == 0 )
  506. {
  507. nFlags |= MF_GRAYED;
  508. } // if: no items in the list
  509. // Add the Properties item to the menu.
  510. strMenuName.LoadString( IDS_MENU_PROPERTIES );
  511. if ( pmenu->AppendMenu( nFlags, ID_FILE_PROPERTIES, strMenuName ) )
  512. {
  513. bHandled = TRUE;
  514. if ( pListBox->GetCurSel() == -1 )
  515. {
  516. pListBox->SetCurSel( 0 );
  517. } // if: no items selected
  518. } // if: successfully added menu item
  519. } // if: menu created successfully
  520. } // try
  521. catch ( CException * pe )
  522. {
  523. pe->ReportError();
  524. pe->Delete();
  525. } // catch: CException
  526. } // if: focus is on list control
  527. if ( bHandled )
  528. {
  529. // Display the menu.
  530. if ( ! pmenu->TrackPopupMenu(
  531. TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  532. point.x,
  533. point.y,
  534. this
  535. ) )
  536. {
  537. } // if: unsuccessfully displayed the menu
  538. } // if: there is a menu to display
  539. else
  540. {
  541. CBasePropertyPage::OnContextMenu( pWnd, point );
  542. } // else: no menu to display
  543. delete pmenu;
  544. } //*** CResourceGeneralPage::OnContextMenu()
  545. /////////////////////////////////////////////////////////////////////////////
  546. //++
  547. //
  548. // CResourceGeneralPage::OnModifyPossibleOwners
  549. //
  550. // Routine Description:
  551. // Handler for the BN_CLICKED message on the Modify Possible Owners button.
  552. //
  553. // Arguments:
  554. // None.
  555. //
  556. // Return Value:
  557. // None.
  558. //
  559. //--
  560. /////////////////////////////////////////////////////////////////////////////
  561. void CResourceGeneralPage::OnModifyPossibleOwners(void)
  562. {
  563. CModifyNodesDlg dlg(
  564. IDD_MODIFY_POSSIBLE_OWNERS,
  565. g_aHelpIDs_IDD_MODIFY_POSSIBLE_OWNERS,
  566. m_lpciPossibleOwners,
  567. PciRes()->PciResourceType()->LpcinodePossibleOwners(),
  568. LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY
  569. );
  570. if (dlg.DoModal() == IDOK)
  571. {
  572. SetModified(TRUE);
  573. FillPossibleOwners();
  574. } // if: OK button pressed
  575. } //*** CResourceGeneralPage::OnModifyPossibleOwners()
  576. /////////////////////////////////////////////////////////////////////////////
  577. //++
  578. //
  579. // CResourceGeneralPage::OnDblClkPossibleOwners
  580. //
  581. // Routine Description:
  582. // Handler for the LBN_DBLCLK message on the Possible Owners listbox.
  583. //
  584. // Arguments:
  585. // None.
  586. //
  587. // Return Value:
  588. // None.
  589. //
  590. //--
  591. /////////////////////////////////////////////////////////////////////////////
  592. void CResourceGeneralPage::OnDblClkPossibleOwners(void)
  593. {
  594. OnProperties();
  595. } //*** CResourceGeneralPage::OnDblClkPossibleOwners()
  596. //*************************************************************************//
  597. /////////////////////////////////////////////////////////////////////////////
  598. // CResourceDependsPage property page
  599. /////////////////////////////////////////////////////////////////////////////
  600. IMPLEMENT_DYNCREATE(CResourceDependsPage, CBasePropertyPage)
  601. /////////////////////////////////////////////////////////////////////////////
  602. // Message Maps
  603. BEGIN_MESSAGE_MAP(CResourceDependsPage, CBasePropertyPage)
  604. //{{AFX_MSG_MAP(CResourceDependsPage)
  605. ON_BN_CLICKED(IDC_PP_RES_MODIFY, OnModify)
  606. ON_NOTIFY(NM_DBLCLK, IDC_PP_RES_DEPENDS_LIST, OnDblClkDependsList)
  607. ON_NOTIFY(LVN_COLUMNCLICK, IDC_PP_RES_DEPENDS_LIST, OnColumnClick)
  608. ON_BN_CLICKED(IDC_PP_RES_PROPERTIES, OnProperties)
  609. ON_WM_CONTEXTMENU()
  610. ON_NOTIFY(LVN_ITEMCHANGED, IDC_PP_RES_DEPENDS_LIST, OnItemChangedDependsList)
  611. //}}AFX_MSG_MAP
  612. ON_COMMAND(ID_FILE_PROPERTIES, OnProperties)
  613. END_MESSAGE_MAP()
  614. /////////////////////////////////////////////////////////////////////////////
  615. //++
  616. //
  617. // CResourceDependsPage::CResourceDependsPage
  618. //
  619. // Routine Description:
  620. // Constructor.
  621. //
  622. // Arguments:
  623. // None.
  624. //
  625. // Return Value:
  626. // None.
  627. //
  628. //--
  629. /////////////////////////////////////////////////////////////////////////////
  630. CResourceDependsPage::CResourceDependsPage(void)
  631. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_RES_DEPENDS)
  632. {
  633. //{{AFX_DATA_INIT(CResourceDependsPage)
  634. //}}AFX_DATA_INIT
  635. m_bQuorumResource = FALSE;
  636. } //*** CResourceDependsPage::CResourceDependsPage()
  637. /////////////////////////////////////////////////////////////////////////////
  638. //++
  639. //
  640. // CResourceDependsPage::BInit
  641. //
  642. // Routine Description:
  643. // Initialize the page.
  644. //
  645. // Arguments:
  646. // psht [IN OUT] Property sheet to which this page belongs.
  647. //
  648. // Return Value:
  649. // TRUE Page initialized successfully.
  650. // FALSE Page failed to initialize.
  651. //
  652. //--
  653. /////////////////////////////////////////////////////////////////////////////
  654. BOOL CResourceDependsPage::BInit(IN OUT CBaseSheet * psht)
  655. {
  656. BOOL bSuccess;
  657. ASSERT_KINDOF(CResourcePropSheet, psht);
  658. // Call the base class to do base-level initialization.
  659. // NOTE: MUST BE DONE BEFORE ACCESSING THE SHEET.
  660. bSuccess = CBasePropertyPage::BInit(psht);
  661. if (bSuccess)
  662. {
  663. try
  664. {
  665. // Duplicate the dependencies list.
  666. {
  667. POSITION pos;
  668. CResource * pciRes;
  669. pos = PciRes()->LpciresDependencies().GetHeadPosition();
  670. while (pos != NULL)
  671. {
  672. pciRes = (CResource *) PciRes()->LpciresDependencies().GetNext(pos);
  673. ASSERT_VALID(pciRes);
  674. m_lpciresDependencies.AddTail(pciRes);
  675. } // while: more nodes in the list
  676. } // Duplicate the dependencies list
  677. // Create the list of resources on which this resource can be dependent.
  678. {
  679. POSITION posPci;
  680. CResource * pciRes;
  681. CResourceList & rlpciResources = PciRes()->Pdoc()->LpciResources();
  682. LpciresAvailable().RemoveAll();
  683. posPci = rlpciResources.GetHeadPosition();
  684. while (posPci != NULL)
  685. {
  686. // Get the cluster item pointer.
  687. pciRes = (CResource *) rlpciResources.GetNext(posPci);
  688. ASSERT_VALID(pciRes);
  689. // If we CAN be dependent on this resource, add it to our Available list.
  690. if (PciRes()->BCanBeDependent(pciRes)
  691. || PciRes()->BIsDependent(pciRes))
  692. LpciresAvailable().AddTail(pciRes);
  693. } // while: more items in the list
  694. } // Create the list of resources on which this resource can be dependent
  695. // Determine if we are the quorum resource.
  696. m_bQuorumResource = (PciRes()->StrName() == PciRes()->Pdoc()->PciCluster()->StrQuorumResource());
  697. } // try
  698. catch (CException * pe)
  699. {
  700. pe->ReportError();
  701. pe->Delete();
  702. bSuccess = FALSE;
  703. } // catch: CException
  704. } // if: base class method was successful
  705. return bSuccess;
  706. } //*** CResourceDependsPage::BInit()
  707. /////////////////////////////////////////////////////////////////////////////
  708. //++
  709. //
  710. // CResourceDependsPage::DoDataExchange
  711. //
  712. // Routine Description:
  713. // Do data exchange between the dialog and the class.
  714. //
  715. // Arguments:
  716. // pDX [IN OUT] Data exchange object
  717. //
  718. // Return Value:
  719. // None.
  720. //
  721. //--
  722. /////////////////////////////////////////////////////////////////////////////
  723. void CResourceDependsPage::DoDataExchange(CDataExchange * pDX)
  724. {
  725. CBasePropertyPage::DoDataExchange(pDX);
  726. //{{AFX_DATA_MAP(CResourceDependsPage)
  727. DDX_Control(pDX, IDC_PP_RES_PROPERTIES, m_pbProperties);
  728. DDX_Control(pDX, IDC_PP_RES_MODIFY, m_pbModify);
  729. DDX_Control(pDX, IDC_PP_RES_DEPENDS_LIST, m_lcDependencies);
  730. //}}AFX_DATA_MAP
  731. if (pDX->m_bSaveAndValidate)
  732. {
  733. } // if: saving data from the dialog
  734. else
  735. {
  736. FillDependencies();
  737. } // else: setting data to the dialog
  738. } //*** CResourceDependsPage::DoDataExchange()
  739. /////////////////////////////////////////////////////////////////////////////
  740. //++
  741. //
  742. // CResourceDependsPage::FillDependencies
  743. //
  744. // Routine Description:
  745. // Fill the Possible Owners list box.
  746. //
  747. // Arguments:
  748. // None.
  749. //
  750. // Return Value:
  751. // None.
  752. //
  753. //--
  754. /////////////////////////////////////////////////////////////////////////////
  755. void CResourceDependsPage::FillDependencies(void)
  756. {
  757. POSITION pos;
  758. int iitem;
  759. int nitem;
  760. CResource * pciRes;
  761. m_lcDependencies.DeleteAllItems();
  762. pos = LpciresDependencies().GetHeadPosition();
  763. for (iitem = 0 ; pos != NULL ; iitem++)
  764. {
  765. pciRes = (CResource *) LpciresDependencies().GetNext(pos);
  766. ASSERT_VALID(pciRes);
  767. nitem = m_lcDependencies.InsertItem(iitem, pciRes->StrName(), pciRes->IimgObjectType());
  768. m_lcDependencies.SetItemText(nitem, 1, pciRes->StrRealResourceTypeDisplayName());
  769. m_lcDependencies.SetItemData(nitem, (DWORD_PTR) pciRes);
  770. } // for: each string in the list
  771. // Sort the items.
  772. m_nSortColumn = 0;
  773. m_nSortDirection = 0;
  774. m_lcDependencies.SortItems(CompareItems, (LPARAM) this);
  775. // If there are any items, set the focus on the first one.
  776. if (m_lcDependencies.GetItemCount() != 0)
  777. m_lcDependencies.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED);
  778. } //*** CResourceDependsPage::FillDependencies()
  779. /////////////////////////////////////////////////////////////////////////////
  780. //++
  781. //
  782. // CResourceDependsPage::OnInitDialog
  783. //
  784. // Routine Description:
  785. // Handler for the WM_INITDIALOG message.
  786. //
  787. // Arguments:
  788. // None.
  789. //
  790. // Return Value:
  791. // TRUE Focus needs to be set.
  792. // FALSE Focus already set.
  793. //
  794. //--
  795. /////////////////////////////////////////////////////////////////////////////
  796. BOOL CResourceDependsPage::OnInitDialog(void)
  797. {
  798. // Call the base class method.
  799. CBasePropertyPage::OnInitDialog();
  800. // Enable the Properties button by default.
  801. m_pbProperties.EnableWindow(FALSE);
  802. // Change list view control extended styles.
  803. {
  804. DWORD dwExtendedStyle;
  805. dwExtendedStyle = (DWORD)m_lcDependencies.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE);
  806. m_lcDependencies.SendMessage(
  807. LVM_SETEXTENDEDLISTVIEWSTYLE,
  808. 0,
  809. dwExtendedStyle
  810. | LVS_EX_FULLROWSELECT
  811. | LVS_EX_HEADERDRAGDROP
  812. );
  813. } // Change list view control extended styles
  814. // Set the image list for the list control to use.
  815. m_lcDependencies.SetImageList(GetClusterAdminApp()->PilSmallImages(), LVSIL_SMALL);
  816. // Add the columns.
  817. {
  818. CString strColumn;
  819. try
  820. {
  821. strColumn.LoadString(IDS_COLTEXT_NAME);
  822. m_lcDependencies.InsertColumn(0, strColumn, LVCFMT_LEFT, COLI_WIDTH_NAME * 3 / 2);
  823. strColumn.LoadString(IDS_COLTEXT_RESTYPE);
  824. m_lcDependencies.InsertColumn(1, strColumn, LVCFMT_LEFT, COLI_WIDTH_RESTYPE * 3 / 2);
  825. } // try
  826. catch (CException * pe)
  827. {
  828. pe->Delete();
  829. } // catch: CException
  830. } // Add the columns
  831. // Fill the list control.
  832. FillDependencies();
  833. if (BReadOnly())
  834. {
  835. m_pbModify.EnableWindow(FALSE);
  836. } // if: read-only page
  837. return TRUE; // return TRUE unless you set the focus to a control
  838. // EXCEPTION: OCX Property Pages should return FALSE
  839. } //*** CResourceDependsPage::OnInitDialog()
  840. /////////////////////////////////////////////////////////////////////////////
  841. //++
  842. //
  843. // CResourceDependsPage::OnApply
  844. //
  845. // Routine Description:
  846. // Handler for the PSM_APPLY message, which is sent when the Apply
  847. // button is pressed.
  848. //
  849. // Arguments:
  850. // None.
  851. //
  852. // Return Value:
  853. // TRUE Page successfully applied.
  854. // FALSE Error applying page.
  855. //
  856. //--
  857. /////////////////////////////////////////////////////////////////////////////
  858. BOOL CResourceDependsPage::OnApply(void)
  859. {
  860. ASSERT(!BReadOnly());
  861. // Check to see if required dependencies have been made.
  862. {
  863. CString strMissing;
  864. CString strMsg;
  865. try
  866. {
  867. if (!PciRes()->BRequiredDependenciesPresent(LpciresDependencies(), strMissing))
  868. {
  869. strMsg.FormatMessage(IDS_REQUIRED_DEPENDENCY_NOT_FOUND, strMissing);
  870. AfxMessageBox(strMsg, MB_OK | MB_ICONSTOP);
  871. return FALSE;
  872. } // if: all required dependencies not present
  873. } // try
  874. catch (CException * pe)
  875. {
  876. pe->ReportError();
  877. pe->Delete();
  878. return FALSE;
  879. } // catch: CException
  880. } // Check to see if required dependencies have been made
  881. // Set the data from the page in the cluster item.
  882. try
  883. {
  884. CWaitCursor wc;
  885. PciRes()->SetDependencies(LpciresDependencies());
  886. } // try
  887. catch (CException * pe)
  888. {
  889. pe->ReportError();
  890. pe->Delete();
  891. return FALSE;
  892. } // catch: CException
  893. return CBasePropertyPage::OnApply();
  894. } //*** CResourceDependsPage::OnApply()
  895. /////////////////////////////////////////////////////////////////////////////
  896. //++
  897. //
  898. // CResourceDependsPage::OnModify
  899. //
  900. // Routine Description:
  901. // Handler for the BN_CLICKED message on the Modify button.
  902. //
  903. // Arguments:
  904. // None.
  905. //
  906. // Return Value:
  907. // None.
  908. //
  909. //--
  910. /////////////////////////////////////////////////////////////////////////////
  911. void CResourceDependsPage::OnModify(void)
  912. {
  913. CModifyResourcesDlg dlg(
  914. IDD_MODIFY_DEPENDENCIES,
  915. g_aHelpIDs_IDD_MODIFY_DEPENDENCIES,
  916. m_lpciresDependencies,
  917. m_lpciresAvailable,
  918. LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY
  919. );
  920. ASSERT(!BReadOnly());
  921. // If this is the quorum resource, display an error message.
  922. if (BQuorumResource())
  923. {
  924. AfxMessageBox(IDS_QUORUM_RES_CANT_HAVE_DEPS);
  925. } // if: this is the quorum resource
  926. else
  927. {
  928. if (dlg.DoModal() == IDOK)
  929. {
  930. SetModified(TRUE);
  931. FillDependencies();
  932. } // if: OK button pressed
  933. } // else: not the quorum resource
  934. } //*** CResourceDependsPage::OnModify()
  935. /////////////////////////////////////////////////////////////////////////////
  936. //++
  937. //
  938. // CResourceDependsPage::OnProperties
  939. //
  940. // Routine Description:
  941. // Handler for the BN_CLICKED message on the Properties button.
  942. //
  943. // Arguments:
  944. // None.
  945. //
  946. // Return Value:
  947. // None.
  948. //
  949. //--
  950. /////////////////////////////////////////////////////////////////////////////
  951. void CResourceDependsPage::OnProperties(void)
  952. {
  953. DisplayProperties();
  954. } //*** CResourceDependsPage::OnProperties()
  955. /////////////////////////////////////////////////////////////////////////////
  956. //++
  957. //
  958. // CListCtrlPair::OnItemChangedDependsList
  959. //
  960. // Routine Description:
  961. // Handler method for the LVN_ITEMCHANGED message in the dependencies
  962. // list.
  963. //
  964. // Arguments:
  965. // pNMHDR [IN OUT] WM_NOTIFY structure.
  966. // pResult [OUT] LRESULT in which to return the result of this operation.
  967. //
  968. // Return Value:
  969. // None.
  970. //
  971. //--
  972. /////////////////////////////////////////////////////////////////////////////
  973. void CResourceDependsPage::OnItemChangedDependsList(NMHDR * pNMHDR, LRESULT * pResult)
  974. {
  975. NM_LISTVIEW * pNMListView = (NM_LISTVIEW *) pNMHDR;
  976. // If the selection changed, enable/disable the Properties button.
  977. if ((pNMListView->uChanged & LVIF_STATE)
  978. && ((pNMListView->uOldState & LVIS_SELECTED)
  979. || (pNMListView->uNewState & LVIS_SELECTED))
  980. && !BReadOnly())
  981. {
  982. UINT cSelected = m_lcDependencies.GetSelectedCount();
  983. // If there is only one item selected, enable the Properties button.
  984. // Otherwise disable it.
  985. m_pbProperties.EnableWindow((cSelected == 1) ? TRUE : FALSE);
  986. } // if: selection changed
  987. *pResult = 0;
  988. } //*** CResourceDependsPage::OnItemChangedDependsList()
  989. /////////////////////////////////////////////////////////////////////////////
  990. //++
  991. //
  992. // CResourceDependsPage::OnContextMenu
  993. //
  994. // Routine Description:
  995. // Handler for the WM_CONTEXTMENU method.
  996. //
  997. // Arguments:
  998. // pWnd Window in which the user right clicked the mouse.
  999. // point Position of the cursor, in screen coordinates.
  1000. //
  1001. // Return Value:
  1002. // None.
  1003. //
  1004. //--
  1005. /////////////////////////////////////////////////////////////////////////////
  1006. void CResourceDependsPage::OnContextMenu(CWnd * pWnd, CPoint point)
  1007. {
  1008. BOOL bHandled = FALSE;
  1009. CMenu * pmenu = NULL;
  1010. CListCtrl * pListCtrl = (CListCtrl *) pWnd;
  1011. CString strMenuName;
  1012. CWaitCursor wc;
  1013. // If focus is not in the list control, don't handle the message.
  1014. if (pWnd == &m_lcDependencies)
  1015. {
  1016. // Create the menu to display.
  1017. try
  1018. {
  1019. pmenu = new CMenu;
  1020. if ( pmenu == NULL )
  1021. {
  1022. AfxThrowMemoryException();
  1023. } // if: error allocating the menu
  1024. if ( pmenu->CreatePopupMenu() )
  1025. {
  1026. UINT nFlags = MF_STRING;
  1027. // If there are no items in the list, disable the menu item.
  1028. if ( pListCtrl->GetItemCount() == 0 )
  1029. {
  1030. nFlags |= MF_GRAYED;
  1031. } // if: no items in the list
  1032. // Add the Properties item to the menu.
  1033. strMenuName.LoadString( IDS_MENU_PROPERTIES );
  1034. if ( pmenu->AppendMenu( nFlags, ID_FILE_PROPERTIES, strMenuName ) )
  1035. {
  1036. bHandled = TRUE;
  1037. if ( ( pListCtrl->GetItemCount() != 0 )
  1038. && ( pListCtrl->GetNextItem( -1, LVNI_FOCUSED ) == -1 ) )
  1039. {
  1040. pListCtrl->SetItemState( 0, LVNI_FOCUSED, LVNI_FOCUSED );
  1041. } // if: no item selected
  1042. } // if: successfully added menu item
  1043. } // if: menu created successfully
  1044. } // try
  1045. catch ( CException * pe )
  1046. {
  1047. pe->ReportError();
  1048. pe->Delete();
  1049. } // catch: CException
  1050. } // if: focus is on the list control
  1051. if ( bHandled )
  1052. {
  1053. // Display the menu.
  1054. if ( ! pmenu->TrackPopupMenu(
  1055. TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  1056. point.x,
  1057. point.y,
  1058. this
  1059. ) )
  1060. {
  1061. } // if: unsuccessfully displayed the menu
  1062. } // if: there is a menu to display
  1063. else
  1064. {
  1065. CBasePropertyPage::OnContextMenu( pWnd, point );
  1066. } // else: no menu to display
  1067. delete pmenu;
  1068. } //*** CResourceDependsPage::OnContextMenu()
  1069. /////////////////////////////////////////////////////////////////////////////
  1070. //++
  1071. //
  1072. // CResourceDependsPage::OnDblClkDependsList
  1073. //
  1074. // Routine Description:
  1075. // Handler method for the NM_DBLCLK message.
  1076. //
  1077. // Arguments:
  1078. // None.
  1079. //
  1080. // Return Value:
  1081. // None.
  1082. //
  1083. //--
  1084. /////////////////////////////////////////////////////////////////////////////
  1085. void CResourceDependsPage::OnDblClkDependsList(NMHDR * pNMHDR, LRESULT * pResult)
  1086. {
  1087. DisplayProperties();
  1088. *pResult = 0;
  1089. } //*** CResourceDependsPage::OnDblClkDependsList()
  1090. /////////////////////////////////////////////////////////////////////////////
  1091. //++
  1092. //
  1093. // CResourceDependsPage::OnColumnClick
  1094. //
  1095. // Routine Description:
  1096. // Handler method for the LVN_COLUMNCLICK message.
  1097. //
  1098. // Arguments:
  1099. // None.
  1100. //
  1101. // Return Value:
  1102. // None.
  1103. //
  1104. //--
  1105. /////////////////////////////////////////////////////////////////////////////
  1106. void CResourceDependsPage::OnColumnClick(NMHDR * pNMHDR, LRESULT * pResult)
  1107. {
  1108. NM_LISTVIEW * pNMListView = (NM_LISTVIEW *) pNMHDR;
  1109. if (m_lcDependencies.GetItemCount() != 0)
  1110. {
  1111. // Save the current sort column and direction.
  1112. if (pNMListView->iSubItem == m_nSortColumn)
  1113. m_nSortDirection ^= -1;
  1114. else
  1115. {
  1116. m_nSortColumn = pNMListView->iSubItem;
  1117. m_nSortDirection = 0;
  1118. } // else: different column
  1119. // Sort the list.
  1120. m_lcDependencies.SortItems(CompareItems, (LPARAM) this);
  1121. } // if: there are items in the list
  1122. *pResult = 0;
  1123. } //*** CResourceDependsPage::OnColumnClick()
  1124. /////////////////////////////////////////////////////////////////////////////
  1125. //++
  1126. //
  1127. // CResourceDependsPage::CompareItems [static]
  1128. //
  1129. // Routine Description:
  1130. // Callback function for the CListCtrl::SortItems method.
  1131. //
  1132. // Arguments:
  1133. // lparam1 First item to compare.
  1134. // lparam2 Second item to compare.
  1135. // lparamSort Sort parameter.
  1136. //
  1137. // Return Value:
  1138. // -1 First parameter comes before second.
  1139. // 0 First and second parameters are the same.
  1140. // 1 First parameter comes after second.
  1141. //
  1142. //--
  1143. /////////////////////////////////////////////////////////////////////////////
  1144. int CALLBACK CResourceDependsPage::CompareItems(
  1145. LPARAM lparam1,
  1146. LPARAM lparam2,
  1147. LPARAM lparamSort
  1148. )
  1149. {
  1150. CResource * pciRes1 = (CResource *) lparam1;
  1151. CResource * pciRes2 = (CResource *) lparam2;
  1152. CResourceDependsPage * ppage = (CResourceDependsPage *) lparamSort;
  1153. const CString * pstr1;
  1154. const CString * pstr2;
  1155. int nResult;
  1156. ASSERT_VALID(pciRes1);
  1157. ASSERT_VALID(pciRes2);
  1158. ASSERT_VALID(ppage);
  1159. // Get the strings from the list items.
  1160. if (ppage->m_nSortColumn == 1)
  1161. {
  1162. pstr1 = &pciRes1->StrRealResourceTypeDisplayName();
  1163. pstr2 = &pciRes2->StrRealResourceTypeDisplayName();
  1164. } // if: sorting on name column
  1165. else
  1166. {
  1167. pstr1 = &pciRes1->StrName();
  1168. pstr2 = &pciRes2->StrName();
  1169. } // else: sorting on resource type column
  1170. // Compare the two strings.
  1171. // Use CompareString() so that it will sort properly on localized builds.
  1172. nResult = CompareString(
  1173. LOCALE_USER_DEFAULT,
  1174. 0,
  1175. *pstr1,
  1176. pstr1->GetLength(),
  1177. *pstr2,
  1178. pstr2->GetLength()
  1179. );
  1180. if ( nResult == CSTR_LESS_THAN )
  1181. {
  1182. nResult = -1;
  1183. }
  1184. else if ( nResult == CSTR_EQUAL )
  1185. {
  1186. nResult = 0;
  1187. }
  1188. else if ( nResult == CSTR_GREATER_THAN )
  1189. {
  1190. nResult = 1;
  1191. }
  1192. else
  1193. {
  1194. // An error occurred. Ignore it.
  1195. nResult = 0;
  1196. }
  1197. // Return the result based on the direction we are sorting.
  1198. if (ppage->m_nSortDirection != 0)
  1199. nResult = -nResult;
  1200. return nResult;
  1201. } //*** CResourceDependsPage::CompareItems()
  1202. /////////////////////////////////////////////////////////////////////////////
  1203. //++
  1204. //
  1205. // CResourceDependsPage::DisplayProperties
  1206. //
  1207. // Routine Description:
  1208. // Display properties of the item with the focus.
  1209. //
  1210. // Arguments:
  1211. // None.
  1212. //
  1213. // Return Value:
  1214. // None.
  1215. //
  1216. //--
  1217. /////////////////////////////////////////////////////////////////////////////
  1218. void CResourceDependsPage::DisplayProperties()
  1219. {
  1220. int iitem;
  1221. CResource * pciRes;
  1222. // Get the item with the focus.
  1223. iitem = m_lcDependencies.GetNextItem(-1, LVNI_FOCUSED);
  1224. ASSERT(iitem != -1);
  1225. if (iitem != -1)
  1226. {
  1227. // Get the resource pointer.
  1228. pciRes = (CResource *) m_lcDependencies.GetItemData(iitem);
  1229. ASSERT_VALID(pciRes);
  1230. // Set properties of that item.
  1231. if (pciRes->BDisplayProperties())
  1232. {
  1233. m_lcDependencies.SetItem(
  1234. iitem,
  1235. 0,
  1236. LVIF_TEXT | LVIF_IMAGE,
  1237. pciRes->StrName(),
  1238. pciRes->IimgObjectType(),
  1239. 0,
  1240. 0,
  1241. 0
  1242. );
  1243. m_lcDependencies.SetItemData(iitem, (DWORD_PTR) pciRes);
  1244. m_lcDependencies.SetItemText(iitem, 1, pciRes->StrRealResourceTypeDisplayName());
  1245. } // if: properties changed
  1246. } // if: found an item with focus
  1247. } //*** CResourceDependsPage::DisplayProperties()
  1248. /////////////////////////////////////////////////////////////////////////////
  1249. //++
  1250. //
  1251. // CResourceDependsPage::BGetNetworkName [static]
  1252. //
  1253. // Routine Description:
  1254. // Get the name of a network name resource on which this resource is
  1255. // dependent.
  1256. //
  1257. // Arguments:
  1258. // lpszNetName [OUT] String in which to return the network name resource name.
  1259. // pcchNetName [IN OUT] Points to a variable that specifies the
  1260. // maximum size, in characters, of the buffer. This
  1261. // value shold be large enough to contain
  1262. // MAX_COMPUTERNAME_LENGTH + 1 characters. Upon
  1263. // return it contains the actual number of characters
  1264. // copied.
  1265. // pvContext [IN OUT] Context for the operation.
  1266. //
  1267. // Return Value:
  1268. // TRUE Resource is dependent on a network name resource.
  1269. // FALSE Resource is NOT dependent on a network name resource.
  1270. //
  1271. //--
  1272. /////////////////////////////////////////////////////////////////////////////
  1273. BOOL CALLBACK CResourceDependsPage::BGetNetworkName(
  1274. OUT WCHAR * lpszNetName,
  1275. IN OUT DWORD * pcchNetName,
  1276. IN OUT PVOID pvContext
  1277. )
  1278. {
  1279. POSITION pos;
  1280. CResource * pciRes;
  1281. CResourceDependsPage * ppage = (CResourceDependsPage *) pvContext;
  1282. ASSERT(lpszNetName != NULL);
  1283. ASSERT(pcchNetName != NULL);
  1284. ASSERT(*pcchNetName > MAX_COMPUTERNAME_LENGTH);
  1285. ASSERT_KINDOF(CResourceDependsPage, ppage);
  1286. pos = ppage->LpciresDependencies().GetHeadPosition();
  1287. while (pos != NULL)
  1288. {
  1289. pciRes = (CResource *) ppage->LpciresDependencies().GetNext(pos);
  1290. ASSERT_VALID(pciRes);
  1291. if (pciRes->StrRealResourceType().CompareNoCase(RESNAME_NETWORK_NAME) == 0)
  1292. {
  1293. DWORD dwStatus;
  1294. CString strNetName;
  1295. HRESULT hr;
  1296. // Read the network name.
  1297. dwStatus = pciRes->DwReadValue(REGPARAM_NAME, REGPARAM_PARAMETERS, strNetName);
  1298. if (dwStatus != ERROR_SUCCESS)
  1299. return FALSE;
  1300. ASSERT(strNetName.GetLength() < (int) *pcchNetName);
  1301. hr = StringCchCopyNW( lpszNetName, *pcchNetName, strNetName, strNetName.GetLength() );
  1302. ASSERT( SUCCEEDED( hr ) );
  1303. return TRUE;
  1304. } // if: found a match
  1305. else if (pciRes->BGetNetworkName(lpszNetName, pcchNetName))
  1306. return TRUE;
  1307. } // while: more items in the list
  1308. ASSERT_VALID(ppage->PciRes());
  1309. // If the resource has a direct dependency on a Network Name resource,
  1310. // we need to return FALSE because the user has removed it from the
  1311. // list here.
  1312. pos = ppage->PciRes()->LpciresDependencies().GetHeadPosition();
  1313. while (pos != NULL)
  1314. {
  1315. pciRes = (CResource *) ppage->PciRes()->LpciresDependencies().GetNext(pos);
  1316. ASSERT_VALID(pciRes);
  1317. if (pciRes->StrRealResourceType().CompareNoCase(RESNAME_NETWORK_NAME) == 0)
  1318. return FALSE;
  1319. } // while: more items in the list
  1320. // There is no direct dependency on a Network Name resource. Call
  1321. // the API to see if there is an indirect dependency.
  1322. return ppage->PciRes()->BGetNetworkName(lpszNetName, pcchNetName);
  1323. } //*** CResourceDependsPage::BGetNetworkName()
  1324. //*************************************************************************//
  1325. /////////////////////////////////////////////////////////////////////////////
  1326. // CResourceAdvancedPage property page
  1327. /////////////////////////////////////////////////////////////////////////////
  1328. IMPLEMENT_DYNCREATE(CResourceAdvancedPage, CBasePropertyPage)
  1329. /////////////////////////////////////////////////////////////////////////////
  1330. // Message Maps
  1331. BEGIN_MESSAGE_MAP(CResourceAdvancedPage, CBasePropertyPage)
  1332. //{{AFX_MSG_MAP(CResourceAdvancedPage)
  1333. ON_BN_CLICKED(IDC_PP_RES_DONT_RESTART, OnClickedDontRestart)
  1334. ON_BN_CLICKED(IDC_PP_RES_RESTART, OnClickedRestart)
  1335. ON_BN_CLICKED(IDC_PP_RES_DEFAULT_LOOKS_ALIVE, OnClickedDefaultLooksAlive)
  1336. ON_BN_CLICKED(IDC_PP_RES_DEFAULT_IS_ALIVE, OnClickedDefaultIsAlive)
  1337. ON_EN_CHANGE(IDC_PP_RES_LOOKS_ALIVE, OnChangeLooksAlive)
  1338. ON_EN_CHANGE(IDC_PP_RES_IS_ALIVE, OnChangeIsAlive)
  1339. ON_BN_CLICKED(IDC_PP_RES_SPECIFY_LOOKS_ALIVE, OnClickedSpecifyLooksAlive)
  1340. ON_BN_CLICKED(IDC_PP_RES_SPECIFY_IS_ALIVE, OnClickedSpecifyIsAlive)
  1341. //}}AFX_MSG_MAP
  1342. ON_BN_CLICKED(IDC_PP_RES_AFFECT_THE_GROUP, CBasePropertyPage::OnChangeCtrl)
  1343. ON_EN_CHANGE(IDC_PP_RES_RESTART_THRESHOLD, CBasePropertyPage::OnChangeCtrl)
  1344. ON_EN_CHANGE(IDC_PP_RES_RESTART_PERIOD, CBasePropertyPage::OnChangeCtrl)
  1345. ON_EN_CHANGE(IDC_PP_RES_PENDING_TIMEOUT, CBasePropertyPage::OnChangeCtrl)
  1346. ON_BN_CLICKED(IDC_PP_RES_SPECIFY_LOOKS_ALIVE, CBasePropertyPage::OnChangeCtrl)
  1347. ON_BN_CLICKED(IDC_PP_RES_SPECIFY_IS_ALIVE, CBasePropertyPage::OnChangeCtrl)
  1348. END_MESSAGE_MAP()
  1349. /////////////////////////////////////////////////////////////////////////////
  1350. //++
  1351. //
  1352. // CResourceAdvancedPage::CResourceAdvancedPage
  1353. //
  1354. // Routine Description:
  1355. // Constructor.
  1356. //
  1357. // Arguments:
  1358. // None.
  1359. //
  1360. // Return Value:
  1361. // None.
  1362. //
  1363. //--
  1364. /////////////////////////////////////////////////////////////////////////////
  1365. CResourceAdvancedPage::CResourceAdvancedPage(void)
  1366. : CBasePropertyPage(IDD, g_aHelpIDs_IDD_PP_RES_ADVANCED)
  1367. {
  1368. //{{AFX_DATA_INIT(CResourceAdvancedPage)
  1369. m_bAffectTheGroup = FALSE;
  1370. m_nRestart = -1;
  1371. //}}AFX_DATA_INIT
  1372. } //*** CResourceAdvancedPage::CResourceAdvancedPage()
  1373. /////////////////////////////////////////////////////////////////////////////
  1374. //++
  1375. //
  1376. // CResourceAdvancedPage::BInit
  1377. //
  1378. // Routine Description:
  1379. // Initialize the page.
  1380. //
  1381. // Arguments:
  1382. // psht [IN OUT] Property sheet to which this page belongs.
  1383. //
  1384. // Return Value:
  1385. // TRUE Page initialized successfully.
  1386. // FALSE Page failed to initialize.
  1387. //
  1388. //--
  1389. /////////////////////////////////////////////////////////////////////////////
  1390. BOOL CResourceAdvancedPage::BInit(IN OUT CBaseSheet * psht)
  1391. {
  1392. BOOL bSuccess;
  1393. ASSERT_KINDOF(CResourcePropSheet, psht);
  1394. bSuccess = CBasePropertyPage::BInit(psht);
  1395. if (bSuccess)
  1396. {
  1397. m_crraRestartAction = PciRes()->CrraRestartAction();
  1398. m_nRestart = 1;
  1399. m_bAffectTheGroup = FALSE;
  1400. if (m_crraRestartAction == ClusterResourceDontRestart)
  1401. m_nRestart = 0;
  1402. else if (m_crraRestartAction == ClusterResourceRestartNotify)
  1403. m_bAffectTheGroup = TRUE;
  1404. m_nThreshold = PciRes()->NRestartThreshold();
  1405. m_nPeriod = PciRes()->NRestartPeriod() / 1000; // display units are seconds, stored units are milliseconds
  1406. m_nLooksAlive = PciRes()->NLooksAlive();
  1407. m_nIsAlive = PciRes()->NIsAlive();
  1408. m_nPendingTimeout = PciRes()->NPendingTimeout() / 1000; // display units are seconds, stored units are milliseconds
  1409. } // if: base class method was successful
  1410. return TRUE;
  1411. } //*** CResourceAdvancedPage::BInit()
  1412. /////////////////////////////////////////////////////////////////////////////
  1413. //++
  1414. //
  1415. // CResourceAdvancedPage::DoDataExchange
  1416. //
  1417. // Routine Description:
  1418. // Do data exchange between the dialog and the class.
  1419. //
  1420. // Arguments:
  1421. // pDX [IN OUT] Data exchange object
  1422. //
  1423. // Return Value:
  1424. // None.
  1425. //
  1426. //--
  1427. /////////////////////////////////////////////////////////////////////////////
  1428. void CResourceAdvancedPage::DoDataExchange(CDataExchange * pDX)
  1429. {
  1430. CBasePropertyPage::DoDataExchange(pDX);
  1431. //{{AFX_DATA_MAP(CResourceAdvancedPage)
  1432. DDX_Control(pDX, IDC_PP_RES_AFFECT_THE_GROUP, m_ckbAffectTheGroup);
  1433. DDX_Control(pDX, IDC_PP_RES_PENDING_TIMEOUT, m_editPendingTimeout);
  1434. DDX_Control(pDX, IDC_PP_RES_DEFAULT_LOOKS_ALIVE, m_rbDefaultLooksAlive);
  1435. DDX_Control(pDX, IDC_PP_RES_SPECIFY_LOOKS_ALIVE, m_rbSpecifyLooksAlive);
  1436. DDX_Control(pDX, IDC_PP_RES_DEFAULT_IS_ALIVE, m_rbDefaultIsAlive);
  1437. DDX_Control(pDX, IDC_PP_RES_SPECIFY_IS_ALIVE, m_rbSpecifyIsAlive);
  1438. DDX_Control(pDX, IDC_PP_RES_LOOKS_ALIVE, m_editLooksAlive);
  1439. DDX_Control(pDX, IDC_PP_RES_IS_ALIVE, m_editIsAlive);
  1440. DDX_Control(pDX, IDC_PP_RES_DONT_RESTART, m_rbDontRestart);
  1441. DDX_Control(pDX, IDC_PP_RES_RESTART, m_rbRestart);
  1442. DDX_Control(pDX, IDC_PP_RES_RESTART_THRESHOLD, m_editThreshold);
  1443. DDX_Control(pDX, IDC_PP_RES_RESTART_PERIOD, m_editPeriod);
  1444. DDX_Check(pDX, IDC_PP_RES_AFFECT_THE_GROUP, m_bAffectTheGroup);
  1445. DDX_Radio(pDX, IDC_PP_RES_DONT_RESTART, m_nRestart);
  1446. //}}AFX_DATA_MAP
  1447. if (pDX->m_bSaveAndValidate)
  1448. {
  1449. CString strValue;
  1450. if (!BReadOnly())
  1451. {
  1452. if (m_nRestart == 1)
  1453. {
  1454. DDX_Number(
  1455. pDX,
  1456. IDC_PP_RES_RESTART_THRESHOLD,
  1457. m_nThreshold,
  1458. CLUSTER_RESOURCE_MINIMUM_RESTART_THRESHOLD,
  1459. CLUSTER_RESOURCE_MAXIMUM_RESTART_THRESHOLD
  1460. );
  1461. DDX_Number(
  1462. pDX,
  1463. IDC_PP_RES_RESTART_PERIOD,
  1464. m_nPeriod,
  1465. CLUSTER_RESOURCE_MINIMUM_RESTART_PERIOD,
  1466. CLUSTER_RESOURCE_MAXIMUM_RESTART_PERIOD / 1000 // display units are seconds, stored units are milliseconds
  1467. );
  1468. } // if: restart is enabled
  1469. if (m_rbDefaultLooksAlive.GetCheck() == BST_CHECKED)
  1470. m_nLooksAlive = CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL;
  1471. else
  1472. DDX_Number(
  1473. pDX,
  1474. IDC_PP_RES_LOOKS_ALIVE,
  1475. m_nLooksAlive,
  1476. CLUSTER_RESOURCE_MINIMUM_LOOKS_ALIVE,
  1477. CLUSTER_RESOURCE_MAXIMUM_LOOKS_ALIVE_UI
  1478. );
  1479. if (m_rbDefaultIsAlive.GetCheck() == BST_CHECKED)
  1480. m_nIsAlive = CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL;
  1481. else
  1482. DDX_Number(
  1483. pDX,
  1484. IDC_PP_RES_IS_ALIVE,
  1485. m_nIsAlive,
  1486. CLUSTER_RESOURCE_MINIMUM_IS_ALIVE,
  1487. CLUSTER_RESOURCE_MAXIMUM_IS_ALIVE_UI
  1488. );
  1489. DDX_Number(
  1490. pDX,
  1491. IDC_PP_RES_PENDING_TIMEOUT,
  1492. m_nPendingTimeout,
  1493. CLUSTER_RESOURCE_MINIMUM_PENDING_TIMEOUT,
  1494. CLUSTER_RESOURCE_MAXIMUM_PENDING_TIMEOUT / 1000 // display units are seconds, stored units are milliseconds
  1495. );
  1496. try
  1497. {
  1498. PciRes()->ValidateCommonProperties(
  1499. PciRes()->StrDescription(),
  1500. PciRes()->BSeparateMonitor(),
  1501. m_nLooksAlive,
  1502. m_nIsAlive,
  1503. m_crraRestartAction,
  1504. m_nThreshold,
  1505. m_nPeriod * 1000, // display units are seconds, stored units are milliseconds
  1506. m_nPendingTimeout * 1000 // display units are seconds, stored units are milliseconds
  1507. );
  1508. } // try
  1509. catch (CException * pe)
  1510. {
  1511. pe->ReportError();
  1512. pe->Delete();
  1513. pDX->Fail();
  1514. } // catch: CException
  1515. } // if: not read only
  1516. } // if: saving data
  1517. else
  1518. {
  1519. DDX_Number(
  1520. pDX,
  1521. IDC_PP_RES_RESTART_THRESHOLD,
  1522. m_nThreshold,
  1523. CLUSTER_RESOURCE_MINIMUM_RESTART_THRESHOLD,
  1524. CLUSTER_RESOURCE_MAXIMUM_RESTART_THRESHOLD
  1525. );
  1526. DDX_Number(
  1527. pDX,
  1528. IDC_PP_RES_RESTART_PERIOD,
  1529. m_nPeriod,
  1530. CLUSTER_RESOURCE_MINIMUM_RESTART_PERIOD,
  1531. CLUSTER_RESOURCE_MAXIMUM_RESTART_PERIOD / 1000 // display units are seconds, stored units are milliseconds
  1532. );
  1533. if (m_nRestart == 0)
  1534. {
  1535. m_rbDontRestart.SetCheck(BST_CHECKED);
  1536. m_rbRestart.SetCheck(BST_UNCHECKED);
  1537. OnClickedDontRestart();
  1538. } // if: Don't Restart selected
  1539. else
  1540. {
  1541. m_rbDontRestart.SetCheck(BST_UNCHECKED);
  1542. m_rbRestart.SetCheck(BST_CHECKED);
  1543. OnClickedRestart();
  1544. } // else: Restart selected
  1545. if (m_nLooksAlive == (DWORD) CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL)
  1546. {
  1547. DWORD nLooksAlive;
  1548. if (PciRes()->PciResourceType() == NULL)
  1549. {
  1550. m_rbDefaultLooksAlive.EnableWindow(FALSE);
  1551. m_rbSpecifyLooksAlive.EnableWindow(FALSE);
  1552. m_editLooksAlive.EnableWindow(FALSE);
  1553. m_editLooksAlive.SetWindowText(_T(""));
  1554. } // if: no resource type
  1555. else
  1556. {
  1557. ASSERT_VALID(PciRes()->PciResourceType());
  1558. nLooksAlive = PciRes()->PciResourceType()->NLooksAlive();
  1559. DDX_Text(pDX, IDC_PP_RES_LOOKS_ALIVE, nLooksAlive);
  1560. m_editLooksAlive.SetReadOnly();
  1561. } // else: resource type known
  1562. m_rbDefaultLooksAlive.SetCheck(BST_CHECKED);
  1563. m_rbSpecifyLooksAlive.SetCheck(BST_UNCHECKED);
  1564. } // if: using default
  1565. else
  1566. {
  1567. m_rbDefaultLooksAlive.SetCheck(BST_UNCHECKED);
  1568. m_rbSpecifyLooksAlive.SetCheck(BST_CHECKED);
  1569. DDX_Number(
  1570. pDX,
  1571. IDC_PP_RES_LOOKS_ALIVE,
  1572. m_nLooksAlive,
  1573. CLUSTER_RESOURCE_MINIMUM_LOOKS_ALIVE,
  1574. CLUSTER_RESOURCE_MAXIMUM_LOOKS_ALIVE_UI
  1575. );
  1576. m_editLooksAlive.SetReadOnly(FALSE);
  1577. } // if: not using default
  1578. if (m_nIsAlive == (DWORD) CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL)
  1579. {
  1580. DWORD nIsAlive;
  1581. if (PciRes()->PciResourceType() == NULL)
  1582. {
  1583. m_rbDefaultIsAlive.EnableWindow(FALSE);
  1584. m_rbSpecifyIsAlive.EnableWindow(FALSE);
  1585. m_editIsAlive.EnableWindow(FALSE);
  1586. m_editIsAlive.SetWindowText(_T(""));
  1587. } // if: no resource type
  1588. else
  1589. {
  1590. ASSERT_VALID(PciRes()->PciResourceType());
  1591. nIsAlive = PciRes()->PciResourceType()->NIsAlive();
  1592. DDX_Text(pDX, IDC_PP_RES_IS_ALIVE, nIsAlive);
  1593. m_editIsAlive.SetReadOnly();
  1594. } // else: resource type known
  1595. m_rbDefaultIsAlive.SetCheck(BST_CHECKED);
  1596. m_rbSpecifyIsAlive.SetCheck(BST_UNCHECKED);
  1597. } // if: using default
  1598. else
  1599. {
  1600. m_rbDefaultIsAlive.SetCheck(BST_UNCHECKED);
  1601. m_rbSpecifyIsAlive.SetCheck(BST_CHECKED);
  1602. DDX_Number(
  1603. pDX,
  1604. IDC_PP_RES_IS_ALIVE,
  1605. m_nIsAlive,
  1606. CLUSTER_RESOURCE_MINIMUM_IS_ALIVE,
  1607. CLUSTER_RESOURCE_MAXIMUM_IS_ALIVE_UI
  1608. );
  1609. m_editIsAlive.SetReadOnly(FALSE);
  1610. } // if: not using default
  1611. DDX_Number(
  1612. pDX,
  1613. IDC_PP_RES_PENDING_TIMEOUT,
  1614. m_nPendingTimeout,
  1615. CLUSTER_RESOURCE_MINIMUM_PENDING_TIMEOUT,
  1616. CLUSTER_RESOURCE_MAXIMUM_PENDING_TIMEOUT / 1000 // display units are seconds, stored units are milliseconds
  1617. );
  1618. } // else: not saving data
  1619. } //*** CResourceAdvancedPage::DoDataExchange()
  1620. /////////////////////////////////////////////////////////////////////////////
  1621. //++
  1622. //
  1623. // CResourceAdvancedPage::OnInitDialog
  1624. //
  1625. // Routine Description:
  1626. // Handler for the WM_INITDIALOG message.
  1627. //
  1628. // Arguments:
  1629. // None.
  1630. //
  1631. // Return Value:
  1632. // TRUE Focus needs to be set.
  1633. // FALSE Focus already set.
  1634. //
  1635. //--
  1636. /////////////////////////////////////////////////////////////////////////////
  1637. BOOL CResourceAdvancedPage::OnInitDialog(void)
  1638. {
  1639. CBasePropertyPage::OnInitDialog();
  1640. // If read-only, set all controls to be either disabled or read-only.
  1641. if (BReadOnly())
  1642. {
  1643. m_rbDontRestart.EnableWindow(FALSE);
  1644. m_rbRestart.EnableWindow(FALSE);
  1645. m_ckbAffectTheGroup.EnableWindow(FALSE);
  1646. m_editThreshold.SetReadOnly(TRUE);
  1647. m_editPeriod.SetReadOnly(TRUE);
  1648. m_rbDefaultLooksAlive.EnableWindow(FALSE);
  1649. m_rbSpecifyLooksAlive.EnableWindow(FALSE);
  1650. m_editLooksAlive.SetReadOnly(TRUE);
  1651. m_rbDefaultIsAlive.EnableWindow(FALSE);
  1652. m_rbSpecifyIsAlive.EnableWindow(FALSE);
  1653. m_editIsAlive.SetReadOnly(TRUE);
  1654. m_editPendingTimeout.SetReadOnly(TRUE);
  1655. } // if: sheet is read-only
  1656. return TRUE; // return TRUE unless you set the focus to a control
  1657. // EXCEPTION: OCX Property Pages should return FALSE
  1658. } //*** CResourceAdvancedPage::OnInitDialog()
  1659. /////////////////////////////////////////////////////////////////////////////
  1660. //++
  1661. //
  1662. // CResourceAdvancedPage::OnApply
  1663. //
  1664. // Routine Description:
  1665. // Handler for when the Apply button is pressed.
  1666. //
  1667. // Arguments:
  1668. // None.
  1669. //
  1670. // Return Value:
  1671. // TRUE Page successfully applied.
  1672. // FALSE Error applying page.
  1673. //
  1674. //--
  1675. /////////////////////////////////////////////////////////////////////////////
  1676. BOOL CResourceAdvancedPage::OnApply(void)
  1677. {
  1678. // Set the data from the page in the cluster item.
  1679. try
  1680. {
  1681. CWaitCursor wc;
  1682. if (m_nRestart == 0)
  1683. m_crraRestartAction = ClusterResourceDontRestart;
  1684. else if (m_bAffectTheGroup)
  1685. m_crraRestartAction = ClusterResourceRestartNotify;
  1686. else
  1687. m_crraRestartAction = ClusterResourceRestartNoNotify;
  1688. PciRes()->SetCommonProperties(
  1689. PciRes()->StrDescription(),
  1690. PciRes()->BSeparateMonitor(),
  1691. m_nLooksAlive,
  1692. m_nIsAlive,
  1693. m_crraRestartAction,
  1694. m_nThreshold,
  1695. m_nPeriod * 1000, // display units are seconds, stored units are milliseconds
  1696. m_nPendingTimeout * 1000 // display units are seconds, stored units are milliseconds
  1697. );
  1698. } // try
  1699. catch (CException * pe)
  1700. {
  1701. pe->ReportError();
  1702. pe->Delete();
  1703. return FALSE;
  1704. } // catch: CException
  1705. return CBasePropertyPage::OnApply();
  1706. } //*** CResourceAdvancedPage::OnApply()
  1707. /////////////////////////////////////////////////////////////////////////////
  1708. //++
  1709. //
  1710. // CResourceAdvancedPage::OnClickedDontRestart
  1711. //
  1712. // Routine Description:
  1713. // Handler for the BN_CLICKED message on the Don't Restart radio button.
  1714. //
  1715. // Arguments:
  1716. // None.
  1717. //
  1718. // Return Value:
  1719. // None.
  1720. //
  1721. //--
  1722. /////////////////////////////////////////////////////////////////////////////
  1723. void CResourceAdvancedPage::OnClickedDontRestart(void)
  1724. {
  1725. // Disable the restart parameter controls.
  1726. m_ckbAffectTheGroup.EnableWindow(FALSE);
  1727. m_editThreshold.EnableWindow(FALSE);
  1728. m_editPeriod.EnableWindow(FALSE);
  1729. // Call the base class method if the state changed.
  1730. if (m_nRestart != 0)
  1731. {
  1732. CBasePropertyPage::OnChangeCtrl();
  1733. } // if: state changed
  1734. } //*** CResourceAdvancedPage::OnClickedDontRestart()
  1735. /////////////////////////////////////////////////////////////////////////////
  1736. //++
  1737. //
  1738. // CResourceAdvancedPage::OnClickedRestart
  1739. //
  1740. // Routine Description:
  1741. // Handler for the BN_CLICKED message on the Restart No Notify radio button.
  1742. //
  1743. // Arguments:
  1744. // None.
  1745. //
  1746. // Return Value:
  1747. // None.
  1748. //
  1749. //--
  1750. /////////////////////////////////////////////////////////////////////////////
  1751. void CResourceAdvancedPage::OnClickedRestart(void)
  1752. {
  1753. // Enable the restart parameter controls.
  1754. m_ckbAffectTheGroup.EnableWindow(TRUE);
  1755. m_editThreshold.EnableWindow(TRUE);
  1756. m_editPeriod.EnableWindow(TRUE);
  1757. // Call the base class method if the state changed.
  1758. if (m_nRestart != 1)
  1759. {
  1760. m_ckbAffectTheGroup.SetCheck(BST_CHECKED);
  1761. CBasePropertyPage::OnChangeCtrl();
  1762. } // if: state changed
  1763. } //*** CResourceAdvancedPage::OnClickedRestart()
  1764. /////////////////////////////////////////////////////////////////////////////
  1765. //++
  1766. //
  1767. // CResourceAdvancedPage::OnChangeLooksAlive
  1768. //
  1769. // Routine Description:
  1770. // Handler for the EN_CHANGE message on the Looks Alive edit control.
  1771. //
  1772. // Arguments:
  1773. // None.
  1774. //
  1775. // Return Value:
  1776. // None.
  1777. //
  1778. //--
  1779. /////////////////////////////////////////////////////////////////////////////
  1780. void CResourceAdvancedPage::OnChangeLooksAlive(void)
  1781. {
  1782. m_rbDefaultLooksAlive.SetCheck(BST_UNCHECKED);
  1783. m_rbSpecifyLooksAlive.SetCheck(BST_CHECKED);
  1784. CBasePropertyPage::OnChangeCtrl();
  1785. } //*** CResourceAdvancedPage::OnChangeLooksAlive()
  1786. /////////////////////////////////////////////////////////////////////////////
  1787. //++
  1788. //
  1789. // CResourceAdvancedPage::OnChangeIsAlive
  1790. //
  1791. // Routine Description:
  1792. // Handler for the EN_CHANGE message on the Is Alive edit control.
  1793. //
  1794. // Arguments:
  1795. // None.
  1796. //
  1797. // Return Value:
  1798. // None.
  1799. //
  1800. //--
  1801. /////////////////////////////////////////////////////////////////////////////
  1802. void CResourceAdvancedPage::OnChangeIsAlive(void)
  1803. {
  1804. m_rbDefaultIsAlive.SetCheck(BST_UNCHECKED);
  1805. m_rbSpecifyIsAlive.SetCheck(BST_CHECKED);
  1806. CBasePropertyPage::OnChangeCtrl();
  1807. } //*** CResourceAdvancedPage::OnChangeIsAlive()
  1808. /////////////////////////////////////////////////////////////////////////////
  1809. //++
  1810. //
  1811. // CResourceAdvancedPage::OnClickedDefaultLooksAlive
  1812. //
  1813. // Routine Description:
  1814. // Handler for the BN_CLICKED message on the Use Default Looks Alive radio button.
  1815. //
  1816. // Arguments:
  1817. // None.
  1818. //
  1819. // Return Value:
  1820. // None.
  1821. //
  1822. //--
  1823. /////////////////////////////////////////////////////////////////////////////
  1824. void CResourceAdvancedPage::OnClickedDefaultLooksAlive(void)
  1825. {
  1826. if (m_nLooksAlive != (DWORD) CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL)
  1827. {
  1828. CString str;
  1829. str.Format(_T("%u"), PciRes()->PciResourceType()->NLooksAlive());
  1830. m_editLooksAlive.SetWindowText(str);
  1831. m_rbDefaultLooksAlive.SetCheck(BST_CHECKED);
  1832. m_rbSpecifyLooksAlive.SetCheck(BST_UNCHECKED);
  1833. m_editLooksAlive.SetReadOnly();
  1834. CBasePropertyPage::OnChangeCtrl();
  1835. } // if: value changed
  1836. } //*** CResourceAdvancedPage::OnClickedDefaultLooksAlive()
  1837. /////////////////////////////////////////////////////////////////////////////
  1838. //++
  1839. //
  1840. // CResourceAdvancedPage::OnClickedDefaultIsAlive
  1841. //
  1842. // Routine Description:
  1843. // Handler for the BN_CLICKED message on the Use Default Is Alive radio button.
  1844. //
  1845. // Arguments:
  1846. // None.
  1847. //
  1848. // Return Value:
  1849. // None.
  1850. //
  1851. //--
  1852. /////////////////////////////////////////////////////////////////////////////
  1853. void CResourceAdvancedPage::OnClickedDefaultIsAlive(void)
  1854. {
  1855. if (m_nIsAlive != (DWORD) CLUSTER_RESOURCE_USE_DEFAULT_POLL_INTERVAL)
  1856. {
  1857. CString str;
  1858. str.Format(_T("%u"), PciRes()->PciResourceType()->NIsAlive());
  1859. m_editIsAlive.SetWindowText(str);
  1860. m_rbDefaultIsAlive.SetCheck(BST_CHECKED);
  1861. m_rbSpecifyIsAlive.SetCheck(BST_UNCHECKED);
  1862. m_editIsAlive.SetReadOnly();
  1863. CBasePropertyPage::OnChangeCtrl();
  1864. } // if: value changed
  1865. } //*** CResourceAdvancedPage::OnClickedDefaultIsAlive()
  1866. /////////////////////////////////////////////////////////////////////////////
  1867. //++
  1868. //
  1869. // CResourceAdvancedPage::OnClickedSpecifyLooksAlive
  1870. //
  1871. // Routine Description:
  1872. // Handler for the BN_CLICKED message on the Specify Looks Alive radio button.
  1873. //
  1874. // Arguments:
  1875. // None.
  1876. //
  1877. // Return Value:
  1878. // None.
  1879. //
  1880. //--
  1881. /////////////////////////////////////////////////////////////////////////////
  1882. void CResourceAdvancedPage::OnClickedSpecifyLooksAlive(void)
  1883. {
  1884. m_editLooksAlive.SetReadOnly(FALSE);
  1885. CBasePropertyPage::OnChangeCtrl();
  1886. } //*** CResourceAdvancedPage::OnClickedSpecifyLooksAlive()
  1887. /////////////////////////////////////////////////////////////////////////////
  1888. //++
  1889. //
  1890. // CResourceAdvancedPage::OnClickedSpecifyIsAlive
  1891. //
  1892. // Routine Description:
  1893. // Handler for the BN_CLICKED message on the Specify Is Alive radio button.
  1894. //
  1895. // Arguments:
  1896. // None.
  1897. //
  1898. // Return Value:
  1899. // None.
  1900. //
  1901. //--
  1902. /////////////////////////////////////////////////////////////////////////////
  1903. void CResourceAdvancedPage::OnClickedSpecifyIsAlive(void)
  1904. {
  1905. m_editIsAlive.SetReadOnly(FALSE);
  1906. CBasePropertyPage::OnChangeCtrl();
  1907. } //*** CResourceAdvancedPage::OnClickedSpecifyIsAlive()