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.

1614 lines
45 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ResWiz.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CCreateResourceWizard class and all pages
  10. // specific to a new resource wizard.
  11. //
  12. // Author:
  13. // David Potter (davidp) September 3, 1996
  14. //
  15. // Revision History:
  16. //
  17. // Notes:
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "CluAdmin.h"
  22. #include "ResWiz.h"
  23. #include "ClusDoc.h"
  24. #include "DDxDDv.h"
  25. #include "HelpData.h"
  26. #include "TreeView.h"
  27. #include "ExcOper.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CCreateResourceWizard
  35. /////////////////////////////////////////////////////////////////////////////
  36. IMPLEMENT_DYNAMIC(CCreateResourceWizard, CBaseWizard)
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Message Maps
  39. BEGIN_MESSAGE_MAP(CCreateResourceWizard, CBaseWizard)
  40. //{{AFX_MSG_MAP(CCreateResourceWizard)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. //++
  45. //
  46. // CCreateResourceWizard::CCreateResourceWizard
  47. //
  48. // Routine Description:
  49. // Constructor.
  50. //
  51. // Arguments:
  52. // pdoc [IN OUT] Document in which resource is to be created.
  53. // pParentWnd [IN OUT] Parent window for this property sheet.
  54. //
  55. // Return Value:
  56. // None.
  57. //
  58. //--
  59. /////////////////////////////////////////////////////////////////////////////
  60. CCreateResourceWizard::CCreateResourceWizard(
  61. IN OUT CClusterDoc * pdoc,
  62. IN OUT CWnd * pParentWnd
  63. )
  64. : CBaseWizard(IDS_NEW_RESOURCE_TITLE, pParentWnd)
  65. {
  66. ASSERT_VALID(pdoc);
  67. m_pdoc = pdoc;
  68. m_pciResType = NULL;
  69. m_pciGroup = NULL;
  70. m_pciRes = NULL;
  71. m_bCreated = FALSE;
  72. m_rgpages[0].m_pwpage = &m_pageName;
  73. m_rgpages[0].m_dwWizButtons = PSWIZB_NEXT;
  74. m_rgpages[1].m_pwpage = &m_pageOwners;
  75. m_rgpages[1].m_dwWizButtons = PSWIZB_BACK | PSWIZB_NEXT;
  76. m_rgpages[2].m_pwpage = &m_pageDependencies;
  77. m_rgpages[2].m_dwWizButtons = PSWIZB_BACK | PSWIZB_NEXT;
  78. } //*** CCreateResourceWizard::CCreateResourceWizard()
  79. /////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CCreateResourceWizard::~CCreateResourceWizard
  83. //
  84. // Routine Description:
  85. // Destructor.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Value:
  91. // None.
  92. //
  93. //--
  94. /////////////////////////////////////////////////////////////////////////////
  95. CCreateResourceWizard::~CCreateResourceWizard(void)
  96. {
  97. if (m_pciRes != NULL)
  98. m_pciRes->Release();
  99. if (m_pciResType != NULL)
  100. m_pciResType->Release();
  101. if (m_pciGroup != NULL)
  102. m_pciGroup->Release();
  103. } //*** CCreateResourceWizard::~CCreateResourceWizard()
  104. /////////////////////////////////////////////////////////////////////////////
  105. //++
  106. //
  107. // CCreateResourceWizard::BInit
  108. //
  109. // Routine Description:
  110. // Initialize the wizard.
  111. //
  112. // Arguments:
  113. // None.
  114. //
  115. // Return Value:
  116. // TRUE Wizard initialized successfully.
  117. // FALSE Wizard not initialized successfully.
  118. //
  119. //--
  120. /////////////////////////////////////////////////////////////////////////////
  121. BOOL CCreateResourceWizard::BInit(void)
  122. {
  123. // Call the base class method.
  124. CClusterAdminApp * papp = GetClusterAdminApp();
  125. if (!CBaseWizard::BInit(papp->Iimg(IMGLI_RES)))
  126. return FALSE;
  127. // Get default group and/or resource type.
  128. {
  129. CTreeItem * pti;
  130. CListItem * pli;
  131. // Get the current MDI frame window.
  132. CSplitterFrame * pframe = (CSplitterFrame *) ((CFrameWnd*)AfxGetMainWnd())->GetActiveFrame();
  133. ASSERT_VALID(pframe);
  134. ASSERT_KINDOF(CSplitterFrame, pframe);
  135. // Get currently selected tree item and list item with focus.
  136. pti = pframe->PviewTree()->PtiSelected();
  137. pli = pframe->PviewList()->PliFocused();
  138. // If the currently selected item in the tree view is a group,
  139. // default to using that group.
  140. ASSERT_VALID(pti);
  141. ASSERT_VALID(pti->Pci());
  142. if (pti->Pci()->IdsType() == IDS_ITEMTYPE_GROUP)
  143. {
  144. ASSERT_KINDOF(CGroup, pti->Pci());
  145. m_pciGroup = (CGroup *) pti->Pci();
  146. } // if: group selected
  147. else
  148. {
  149. // If the item with the focus in the list control is a group,
  150. // default to using it. If it is a resource, use its group.
  151. if (pli != NULL)
  152. {
  153. ASSERT_VALID(pli->Pci());
  154. if (pli->Pci()->IdsType() == IDS_ITEMTYPE_GROUP)
  155. {
  156. ASSERT_KINDOF(CGroup, pli->Pci());
  157. m_pciGroup = (CGroup *) pli->Pci();
  158. } // if: group has focus
  159. else if (pli->Pci()->IdsType() == IDS_ITEMTYPE_RESOURCE)
  160. {
  161. ASSERT_KINDOF(CResource, pli->Pci());
  162. m_pciGroup = ((CResource *) pli->Pci())->PciGroup();
  163. } // else if: resource has focus
  164. } // if: a list item has focus
  165. } // else: tree item not a group
  166. // Increment the reference count on the group.
  167. if (m_pciGroup != NULL)
  168. m_pciGroup->AddRef();
  169. // If a resource is selected, set the default resource type from it.
  170. // If a resource type is selected, set the default resource type to it.
  171. if (pli != NULL)
  172. {
  173. ASSERT_VALID(pli->Pci());
  174. if (pli->Pci()->IdsType() == IDS_ITEMTYPE_RESOURCE)
  175. {
  176. ASSERT_KINDOF(CResource, pli->Pci());
  177. m_pciResType = ((CResource *) pli->Pci())->PciResourceType();
  178. } // if: resource has focus
  179. else if (pli->Pci()->IdsType() == IDS_ITEMTYPE_RESTYPE)
  180. {
  181. ASSERT_KINDOF(CResourceType, pli->Pci());
  182. m_pciResType = (CResourceType *) pli->Pci();
  183. } // else if: resource type has focus
  184. } // if: a list item has focus
  185. // Increment the reference count on the resource type.
  186. if (m_pciResType != NULL)
  187. m_pciResType->AddRef();
  188. } // // Get currently selected group
  189. return TRUE;
  190. } //*** CCreateResourceWizard::BInit()
  191. /////////////////////////////////////////////////////////////////////////////
  192. //++
  193. //
  194. // CCreateResourceWizard::OnCancel
  195. //
  196. // Routine Description:
  197. // Called after the wizard has been dismissed when the Cancel button
  198. // has been pressed.
  199. //
  200. // Arguments:
  201. // None.
  202. //
  203. // Return Value:
  204. // None.
  205. //
  206. //--
  207. /////////////////////////////////////////////////////////////////////////////
  208. void CCreateResourceWizard::OnCancel(void)
  209. {
  210. if (BCreated())
  211. {
  212. ASSERT_VALID(PciRes());
  213. try
  214. {
  215. PciRes()->DeleteResource();
  216. } // try
  217. catch (CException * pe)
  218. {
  219. pe->ReportError();
  220. pe->Delete();
  221. } // catch: CException
  222. catch (...)
  223. {
  224. } // catch: anything
  225. m_bCreated = FALSE;
  226. } // if: we created the object
  227. } //*** CCreateResourceWizard::OnCancel()
  228. /////////////////////////////////////////////////////////////////////////////
  229. //++
  230. //
  231. // CBaseWizard::OnWizardFinish
  232. //
  233. // Routine Description:
  234. // Called after the wizard has been dismissed when the Finish button
  235. // has been pressed.
  236. //
  237. // Arguments:
  238. // None.
  239. //
  240. // Return Value:
  241. // None.
  242. //
  243. //--
  244. /////////////////////////////////////////////////////////////////////////////
  245. void CCreateResourceWizard::OnWizardFinish(void)
  246. {
  247. CResource * pciResDoc;
  248. ASSERT_VALID(PciRes());
  249. try
  250. {
  251. pciResDoc = (CResource *) Pdoc()->LpciResources().PciFromName(PciRes()->StrName());
  252. ASSERT_VALID(pciResDoc);
  253. if (pciResDoc != NULL)
  254. pciResDoc->ReadItem();
  255. } // try
  256. catch (CException * pe)
  257. {
  258. pe->ReportError();
  259. pe->Delete();
  260. } // catch: CException
  261. } //*** CCreateResourceWizard::OnWizardFinish()
  262. /////////////////////////////////////////////////////////////////////////////
  263. //++
  264. //
  265. // CCreateResourceWizard::Ppages
  266. //
  267. // Routine Description:
  268. // Returns the array of pages to add to the property sheet.
  269. //
  270. // Arguments:
  271. // None.
  272. //
  273. // Return Value:
  274. // Page array.
  275. //
  276. //--
  277. /////////////////////////////////////////////////////////////////////////////
  278. CWizPage * CCreateResourceWizard::Ppages(void)
  279. {
  280. return m_rgpages;
  281. } //*** CCreateResourceWizard::Ppages()
  282. /////////////////////////////////////////////////////////////////////////////
  283. //++
  284. //
  285. // CCreateResourceWizard::Cpages
  286. //
  287. // Routine Description:
  288. // Returns the count of pages in the array.
  289. //
  290. // Arguments:
  291. // None.
  292. //
  293. // Return Value:
  294. // Count of pages in the array.
  295. //
  296. //--
  297. /////////////////////////////////////////////////////////////////////////////
  298. int CCreateResourceWizard::Cpages(void)
  299. {
  300. return sizeof(m_rgpages) / sizeof(CWizPage);
  301. } //*** CCreateResourceWizard::Cpages()
  302. /////////////////////////////////////////////////////////////////////////////
  303. //++
  304. //
  305. // CCreateResourceWizard::BSetRequiredFields
  306. //
  307. // Routine Description:
  308. // Set the required fields of the resource, creating it if necessary.
  309. //
  310. // Arguments:
  311. // rstrName [IN] Name of the resource.
  312. // pciResType [IN] The resource type of the resource.
  313. // pciGroup [IN] The group to which the resource belongs.
  314. // bSeparateMonitor [IN] TRUE = Resource runs in a separate moniotor.
  315. // rstrDesc [IN] Description of the resource.
  316. //
  317. // Return Value:
  318. // TRUE Required fields set successfully.
  319. // FALSE Error setting the required fields.
  320. //
  321. //--
  322. /////////////////////////////////////////////////////////////////////////////
  323. BOOL CCreateResourceWizard::BSetRequiredFields(
  324. IN const CString & rstrName,
  325. IN CResourceType * pciResType,
  326. IN CGroup * pciGroup,
  327. IN BOOL bSeparateMonitor,
  328. IN const CString & rstrDesc
  329. )
  330. {
  331. BOOL bSuccess = TRUE;
  332. CResource * pciResDoc;
  333. CWaitCursor wc;
  334. ASSERT(pciGroup != NULL);
  335. try
  336. {
  337. if ( BCreated()
  338. && ( (pciResType->StrName().CompareNoCase(PciRes()->StrRealResourceType()) != 0)
  339. || (PciRes()->PciGroup() == NULL)
  340. || (pciGroup->StrName().CompareNoCase(PciRes()->PciGroup()->StrName()) != 0)))
  341. {
  342. PciRes()->DeleteResource();
  343. m_bCreated = FALSE;
  344. } // if: object created already but resource type changed
  345. if (!BCreated())
  346. {
  347. // Allocate an item.
  348. if (PciRes() != NULL)
  349. {
  350. VERIFY(m_pciRes->Release() == 0);
  351. } // if: item already allocated
  352. m_pciRes = new CResource(FALSE);
  353. if ( m_pciRes == NULL )
  354. {
  355. AfxThrowMemoryException();
  356. } // if: error allocating the resource
  357. m_pciRes->AddRef();
  358. // Create the resource.
  359. PciRes()->Create(
  360. Pdoc(),
  361. rstrName,
  362. pciResType->StrName(),
  363. pciGroup->StrName(),
  364. bSeparateMonitor
  365. );
  366. // Create the resource in the document.
  367. pciResDoc = Pdoc()->PciAddNewResource(rstrName);
  368. if (pciResDoc != NULL)
  369. pciResDoc->SetInitializing();
  370. // Read the resource.
  371. PciRes()->ReadItem();
  372. // Set the description field.
  373. try
  374. {
  375. PciRes()->SetCommonProperties(
  376. rstrDesc,
  377. bSeparateMonitor,
  378. PciRes()->NLooksAlive(),
  379. PciRes()->NIsAlive(),
  380. PciRes()->CrraRestartAction(),
  381. PciRes()->NRestartThreshold(),
  382. PciRes()->NRestartPeriod(),
  383. PciRes()->NPendingTimeout()
  384. );
  385. } // try
  386. catch (CNTException * pnte)
  387. {
  388. if (pnte->Sc() != ERROR_RESOURCE_PROPERTIES_STORED)
  389. throw;
  390. pnte->Delete();
  391. } // catch: CNTException
  392. m_strName = rstrName;
  393. m_strDescription = rstrDesc;
  394. m_bCreated = TRUE;
  395. m_bNeedToLoadExtensions = TRUE;
  396. } // if: object not created yet
  397. else
  398. {
  399. ASSERT_VALID(PciRes());
  400. // If the group changed, clear the dependencies.
  401. if (pciGroup->StrName() != PciRes()->StrGroup())
  402. {
  403. CResourceList lpobjRes;
  404. PciRes()->SetDependencies(lpobjRes);
  405. PciRes()->SetGroup(pciGroup->StrName());
  406. } // if: group name changed
  407. PciRes()->SetName(rstrName);
  408. try
  409. {
  410. PciRes()->SetCommonProperties(
  411. rstrDesc,
  412. bSeparateMonitor,
  413. PciRes()->NLooksAlive(),
  414. PciRes()->NIsAlive(),
  415. PciRes()->CrraRestartAction(),
  416. PciRes()->NRestartThreshold(),
  417. PciRes()->NRestartPeriod(),
  418. PciRes()->NPendingTimeout()
  419. );
  420. } // try
  421. catch (CNTException * pnte)
  422. {
  423. if (pnte->Sc() != ERROR_RESOURCE_PROPERTIES_STORED)
  424. throw;
  425. pnte->Delete();
  426. } // catch: CNTException
  427. m_strName = rstrName;
  428. m_strDescription = rstrDesc;
  429. } // else: object already exists
  430. // Save the resource type pointer.
  431. if (pciResType != m_pciResType)
  432. {
  433. pciResType->AddRef();
  434. if (m_pciResType != NULL)
  435. m_pciResType->Release();
  436. m_pciResType = pciResType;
  437. } // if: the resource type changed
  438. // Save the group pointer.
  439. if (pciGroup != m_pciGroup)
  440. {
  441. pciGroup->AddRef();
  442. if (m_pciGroup != NULL)
  443. m_pciGroup->Release();
  444. m_pciGroup = pciGroup;
  445. } // if: the group changed
  446. } // try
  447. catch (CException * pe)
  448. {
  449. pe->ReportError();
  450. pe->Delete();
  451. if (PciRes() != NULL)
  452. {
  453. try
  454. {
  455. PciRes()->DeleteResource();
  456. } // try
  457. catch (...)
  458. {
  459. } // catch: Anything
  460. VERIFY(m_pciRes->Release() == 0);
  461. m_pciRes = NULL;
  462. m_bCreated = FALSE;
  463. } // if: there is a resource
  464. bSuccess = FALSE;
  465. } // catch: CException
  466. return bSuccess;
  467. } //*** CCreateResourceWizard::BSetRequiredFields()
  468. //*************************************************************************//
  469. /////////////////////////////////////////////////////////////////////////////
  470. // CNewResNamePage property page
  471. /////////////////////////////////////////////////////////////////////////////
  472. IMPLEMENT_DYNCREATE(CNewResNamePage, CBaseWizardPage)
  473. /////////////////////////////////////////////////////////////////////////////
  474. // Message Maps
  475. BEGIN_MESSAGE_MAP(CNewResNamePage, CBaseWizardPage)
  476. //{{AFX_MSG_MAP(CNewResNamePage)
  477. ON_EN_CHANGE(IDC_WIZ_RES_NAME, OnChangeResName)
  478. ON_EN_KILLFOCUS(IDC_WIZ_RES_NAME, OnKillFocusResName)
  479. ON_WM_DESTROY()
  480. //}}AFX_MSG_MAP
  481. END_MESSAGE_MAP()
  482. /////////////////////////////////////////////////////////////////////////////
  483. //++
  484. //
  485. // CNewResNamePage::CNewResNamePage
  486. //
  487. // Routine Description:
  488. // Default constructor.
  489. //
  490. // Arguments:
  491. // None.
  492. //
  493. // Return Value:
  494. // None.
  495. //
  496. //--
  497. /////////////////////////////////////////////////////////////////////////////
  498. CNewResNamePage::CNewResNamePage(void)
  499. : CBaseWizardPage(IDD, g_aHelpIDs_IDD_WIZ_RESOURCE_NAME)
  500. {
  501. //{{AFX_DATA_INIT(CNewResNamePage)
  502. m_strName = _T("");
  503. m_strDesc = _T("");
  504. m_strGroup = _T("");
  505. m_strResType = _T("");
  506. m_bSeparateMonitor = FALSE;
  507. //}}AFX_DATA_INIT
  508. m_pciResType = NULL;
  509. m_pciGroup = NULL;
  510. } //*** CNewResNamePage::CNewResNamePage()
  511. /////////////////////////////////////////////////////////////////////////////
  512. //++
  513. //
  514. // CNewResNamePage::DoDataExchange
  515. //
  516. // Routine Description:
  517. // Do data exchange between the dialog and the class.
  518. //
  519. // Arguments:
  520. // pDX [IN OUT] Data exchange object
  521. //
  522. // Return Value:
  523. // None.
  524. //
  525. //--
  526. /////////////////////////////////////////////////////////////////////////////
  527. void CNewResNamePage::DoDataExchange(CDataExchange * pDX)
  528. {
  529. CBaseWizardPage::DoDataExchange(pDX);
  530. //{{AFX_DATA_MAP(CNewResNamePage)
  531. DDX_Control(pDX, IDC_WIZ_RES_GROUP, m_cboxGroups);
  532. DDX_Control(pDX, IDC_WIZ_RES_RESTYPE, m_cboxResTypes);
  533. DDX_Control(pDX, IDC_WIZ_RES_DESC, m_editDesc);
  534. DDX_Control(pDX, IDC_WIZ_RES_NAME, m_editName);
  535. DDX_Text(pDX, IDC_WIZ_RES_NAME, m_strName);
  536. DDX_Text(pDX, IDC_WIZ_RES_DESC, m_strDesc);
  537. DDX_CBString(pDX, IDC_WIZ_RES_GROUP, m_strGroup);
  538. DDX_CBString(pDX, IDC_WIZ_RES_RESTYPE, m_strResType);
  539. DDX_Check(pDX, IDC_WIZ_RES_SEPARATE_MONITOR, m_bSeparateMonitor);
  540. //}}AFX_DATA_MAP
  541. DDV_RequiredText(pDX, IDC_WIZ_RES_NAME, IDC_WIZ_RES_NAME_LABEL, m_strName);
  542. if (pDX->m_bSaveAndValidate)
  543. {
  544. int icbi;
  545. icbi = m_cboxResTypes.GetCurSel();
  546. ASSERT(icbi != CB_ERR);
  547. m_pciResType = (CResourceType *) m_cboxResTypes.GetItemDataPtr(icbi);
  548. icbi = m_cboxGroups.GetCurSel();
  549. ASSERT(icbi != CB_ERR);
  550. m_pciGroup = (CGroup *) m_cboxGroups.GetItemDataPtr(icbi);
  551. } // if: saving data from dialog
  552. else
  553. {
  554. // Select the proper resource type item.
  555. if (m_cboxResTypes.GetCurSel() == CB_ERR)
  556. m_cboxResTypes.SetCurSel(0);
  557. // Select the proper group item.
  558. if (m_cboxGroups.GetCurSel() == CB_ERR)
  559. m_cboxGroups.SetCurSel(0);
  560. } // else: setting to dialog
  561. } //*** CNewResNamePage::DoDataExchange()
  562. /////////////////////////////////////////////////////////////////////////////
  563. //++
  564. //
  565. // CNewResNamePage::OnInitDialog
  566. //
  567. // Routine Description:
  568. // Handler for the WM_INITDIALOG message.
  569. //
  570. // Arguments:
  571. // None.
  572. //
  573. // Return Value:
  574. // TRUE Focus needs to be set.
  575. // FALSE Focus already set.
  576. //
  577. //--
  578. /////////////////////////////////////////////////////////////////////////////
  579. BOOL CNewResNamePage::OnInitDialog(void)
  580. {
  581. CBaseWizardPage::OnInitDialog();
  582. // Fill the Resource Type list.
  583. {
  584. POSITION pos;
  585. CResourceType * pciResType;
  586. int icbi;
  587. CDC * pCboxDC;
  588. CFont * pfontOldFont;
  589. CFont * pfontCBFont;
  590. int nCboxHorizExtent = 0;
  591. CSize cboxTextSize;
  592. TEXTMETRIC tm;
  593. tm.tmAveCharWidth = 0;
  594. //
  595. // Refer to Knowledge base article Q66370 for details on how to
  596. // set the horizontal extent of a list box (or drop list).
  597. //
  598. pCboxDC = m_cboxResTypes.GetDC(); // Get the device context (DC) from the combo box.
  599. pfontCBFont = m_cboxResTypes.GetFont(); // Get the combo box font.
  600. pfontOldFont = pCboxDC->SelectObject(pfontCBFont); // Select this font into the DC. Save the old font.
  601. pCboxDC->GetTextMetrics(&tm); // Get the text metrics of this DC.
  602. pos = PwizRes()->Pdoc()->LpciResourceTypes().GetHeadPosition();
  603. while (pos != NULL)
  604. {
  605. pciResType = (CResourceType *) PwizRes()->Pdoc()->LpciResourceTypes().GetNext(pos);
  606. const CString &rstrCurResTypeString = pciResType->StrDisplayName();
  607. ASSERT_VALID(pciResType);
  608. if ( (pciResType->Hkey() != NULL)
  609. && (rstrCurResTypeString.GetLength() > 0)
  610. && (pciResType->StrName() != CLUS_RESTYPE_NAME_FTSET)
  611. )
  612. {
  613. icbi = m_cboxResTypes.AddString(rstrCurResTypeString);
  614. // Compute the horizontal extent of this string.
  615. cboxTextSize = pCboxDC->GetTextExtent(rstrCurResTypeString);
  616. if (cboxTextSize.cx > nCboxHorizExtent)
  617. {
  618. nCboxHorizExtent = cboxTextSize.cx;
  619. }
  620. ASSERT(icbi != CB_ERR);
  621. m_cboxResTypes.SetItemDataPtr(icbi, pciResType);
  622. pciResType->AddRef();
  623. } // if: resource type is valid
  624. } // while: more items in the list
  625. pCboxDC->SelectObject(pfontOldFont); // Reset the original font in the DC
  626. m_cboxResTypes.ReleaseDC(pCboxDC); // Release the DC
  627. m_cboxResTypes.SetHorizontalExtent(nCboxHorizExtent + tm.tmAveCharWidth);
  628. } // Fill the Resource Type list
  629. // Fill the Group list.
  630. {
  631. POSITION pos;
  632. CGroup * pciGroup;
  633. int icbi;
  634. pos = PwizRes()->Pdoc()->LpciGroups().GetHeadPosition();
  635. while (pos != NULL)
  636. {
  637. pciGroup = (CGroup *) PwizRes()->Pdoc()->LpciGroups().GetNext(pos);
  638. ASSERT_VALID(pciGroup);
  639. if ( (pciGroup->Hgroup() != NULL)
  640. && (pciGroup->Hkey() != NULL))
  641. {
  642. icbi = m_cboxGroups.AddString(pciGroup->StrName());
  643. ASSERT(icbi != CB_ERR);
  644. m_cboxGroups.SetItemDataPtr(icbi, pciGroup);
  645. pciGroup->AddRef();
  646. } // if: group is valid
  647. } // while: more items in the list
  648. } // Fill the Group list
  649. // If there is a group already selected, get its name.
  650. if (PwizRes()->PciGroup() != NULL)
  651. m_strGroup = PwizRes()->PciGroup()->StrName();
  652. // If there is a resource type already selected, get its name.
  653. if (PwizRes()->PciResType() != NULL)
  654. m_strResType = PwizRes()->PciResType()->StrName();
  655. UpdateData(FALSE /*bSaveAndValidate*/);
  656. return TRUE; // return TRUE unless you set the focus to a control
  657. // EXCEPTION: OCX Property Pages should return FALSE
  658. } //*** CNewResNamePage::OnInitDialog()
  659. /////////////////////////////////////////////////////////////////////////////
  660. //++
  661. //
  662. // CNewResNamePage::OnSetActive
  663. //
  664. // Routine Description:
  665. // Handler for the PSN_SETACTIVE message.
  666. //
  667. // Arguments:
  668. // None.
  669. //
  670. // Return Value:
  671. // TRUE Page successfully initialized.
  672. // FALSE Page not initialized.
  673. //
  674. //--
  675. /////////////////////////////////////////////////////////////////////////////
  676. BOOL CNewResNamePage::OnSetActive(void)
  677. {
  678. BOOL bSuccess;
  679. bSuccess = CBaseWizardPage::OnSetActive();
  680. if (bSuccess)
  681. {
  682. if (m_strName.IsEmpty())
  683. EnableNext(FALSE);
  684. } // if: successful thus far
  685. return bSuccess;
  686. } //*** CNewResNamePage::OnSetActive()
  687. /////////////////////////////////////////////////////////////////////////////
  688. //++
  689. //
  690. // CNewResNamePage::BApplyChanges
  691. //
  692. // Routine Description:
  693. // Apply changes from this page.
  694. //
  695. // Arguments:
  696. // None.
  697. //
  698. // Return Value:
  699. // TRUE Changes applied successfully.
  700. // FALSE Error applying changes.
  701. //
  702. //--
  703. /////////////////////////////////////////////////////////////////////////////
  704. BOOL CNewResNamePage::BApplyChanges(void)
  705. {
  706. CWaitCursor wc;
  707. ASSERT(Pwiz() != NULL);
  708. // Get the data from the dialog.
  709. if (!UpdateData(TRUE /*bSaveAndValidate*/))
  710. return FALSE;
  711. // Save the data in the sheet.
  712. if (!PwizRes()->BSetRequiredFields(
  713. m_strName,
  714. m_pciResType,
  715. m_pciGroup,
  716. m_bSeparateMonitor,
  717. m_strDesc))
  718. return FALSE;
  719. // Load extensions here.
  720. Pwiz()->LoadExtensions(PwizRes()->PciRes());
  721. return TRUE;
  722. } //*** CNewResNamePage::BApplyChanges()
  723. /////////////////////////////////////////////////////////////////////////////
  724. //++
  725. //
  726. // CNewResNamePage::OnDestroy
  727. //
  728. // Routine Description:
  729. // Handler for the WM_DESTROY message.
  730. //
  731. // Arguments:
  732. // None.
  733. //
  734. // Return Value:
  735. // None.
  736. //
  737. //--
  738. /////////////////////////////////////////////////////////////////////////////
  739. void CNewResNamePage::OnDestroy(void)
  740. {
  741. // Release references on resource type pointers.
  742. if (m_cboxResTypes.m_hWnd != NULL)
  743. {
  744. int icbi;
  745. CResourceType * pciResType;
  746. for (icbi = m_cboxResTypes.GetCount() - 1 ; icbi >= 0 ; icbi--)
  747. {
  748. pciResType = (CResourceType *) m_cboxResTypes.GetItemDataPtr(icbi);
  749. ASSERT_VALID(pciResType);
  750. ASSERT_KINDOF(CResourceType, pciResType);
  751. pciResType->Release();
  752. } // while: more items in the list control
  753. } // if: resource types combobox has been initialized
  754. // Release references on group pointers.
  755. if (m_cboxGroups.m_hWnd != NULL)
  756. {
  757. int icbi;
  758. CGroup * pciGroup;
  759. for (icbi = m_cboxGroups.GetCount() - 1 ; icbi >= 0 ; icbi--)
  760. {
  761. pciGroup = (CGroup *) m_cboxGroups.GetItemDataPtr(icbi);
  762. ASSERT_VALID(pciGroup);
  763. ASSERT_KINDOF(CGroup, pciGroup);
  764. pciGroup->Release();
  765. } // while: more items in the list control
  766. } // if: groups combobox has been initialized
  767. CBaseWizardPage::OnDestroy();
  768. } //*** CNewResNamePage::OnDestroy()
  769. /////////////////////////////////////////////////////////////////////////////
  770. //++
  771. //
  772. // CNewResNamePage::OnChangeResName
  773. //
  774. // Routine Description:
  775. // Handler for the EN_CHANGE message on the Resource Name edit control.
  776. //
  777. // Arguments:
  778. // None.
  779. //
  780. // Return Value:
  781. // None.
  782. //
  783. //--
  784. /////////////////////////////////////////////////////////////////////////////
  785. void CNewResNamePage::OnChangeResName(void)
  786. {
  787. if (m_editName.GetWindowTextLength() == 0)
  788. EnableNext(FALSE);
  789. else
  790. EnableNext(TRUE);
  791. } //*** CNewResNamePage::OnChangeResName()
  792. /////////////////////////////////////////////////////////////////////////////
  793. //++
  794. //
  795. // CNewResNamePage::OnKillFocusResName
  796. //
  797. // Routine Description:
  798. // Handler for the WM_KILLFOCUS message on the Resource Name edit control.
  799. //
  800. // Arguments:
  801. // None.
  802. //
  803. // Return Value:
  804. // None.
  805. //
  806. //--
  807. /////////////////////////////////////////////////////////////////////////////
  808. void CNewResNamePage::OnKillFocusResName(void)
  809. {
  810. CString strName;
  811. m_editName.GetWindowText(strName);
  812. SetObjectTitle(strName);
  813. } //*** CNewResNamePage::OnKillFocusResName()
  814. //*************************************************************************//
  815. /////////////////////////////////////////////////////////////////////////////
  816. // CNewResOwnersPage property page
  817. /////////////////////////////////////////////////////////////////////////////
  818. IMPLEMENT_DYNCREATE(CNewResOwnersPage, CListCtrlPairWizPage)
  819. /////////////////////////////////////////////////////////////////////////////
  820. // Message Maps
  821. /////////////////////////////////////////////////////////////////////////////
  822. BEGIN_MESSAGE_MAP(CNewResOwnersPage, CListCtrlPairWizPage)
  823. //{{AFX_MSG_MAP(CNewResOwnersPage)
  824. //}}AFX_MSG_MAP
  825. END_MESSAGE_MAP()
  826. /////////////////////////////////////////////////////////////////////////////
  827. //++
  828. //
  829. // CNewResOwnersPage::CNewResOwnersPage
  830. //
  831. // Routine Description:
  832. // Constructor.
  833. //
  834. // Arguments:
  835. // None.
  836. //
  837. // Return Value:
  838. // None.
  839. //
  840. //--
  841. /////////////////////////////////////////////////////////////////////////////
  842. CNewResOwnersPage::CNewResOwnersPage(void)
  843. : CListCtrlPairWizPage(
  844. IDD,
  845. g_aHelpIDs_IDD_WIZ_POSSIBLE_OWNERS,
  846. LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY,
  847. GetColumn,
  848. BDisplayProperties
  849. )
  850. {
  851. //{{AFX_DATA_INIT(CNewResOwnersPage)
  852. //}}AFX_DATA_INIT
  853. } //*** CNewResOwnersPage::CNewResOwnersPage()
  854. /////////////////////////////////////////////////////////////////////////////
  855. //++
  856. //
  857. // CNewResOwnersPage::DoDataExchange
  858. //
  859. // Routine Description:
  860. // Do data exchange between the dialog and the class.
  861. //
  862. // Arguments:
  863. // pDX [IN OUT] Data exchange object
  864. //
  865. // Return Value:
  866. // None.
  867. //
  868. //--
  869. /////////////////////////////////////////////////////////////////////////////
  870. void CNewResOwnersPage::DoDataExchange(CDataExchange * pDX)
  871. {
  872. // Initialize the lists before the list pair control is updated.
  873. if (!pDX->m_bSaveAndValidate)
  874. {
  875. if (!BInitLists())
  876. pDX->Fail();
  877. } // if: setting data to the dialog
  878. CListCtrlPairWizPage::DoDataExchange(pDX);
  879. //{{AFX_DATA_MAP(CNewResOwnersPage)
  880. DDX_Control(pDX, IDC_LCP_NOTE, m_staticNote);
  881. //}}AFX_DATA_MAP
  882. if (pDX->m_bSaveAndValidate)
  883. {
  884. if (!BBackPressed())
  885. {
  886. #if 0
  887. // If user removed node on which group is online,
  888. // display message and fail.
  889. if (!BOwnedByPossibleOwner())
  890. {
  891. CString strMsg;
  892. strMsg.FormatMessage(IDS_RES_NOT_OWNED_BY_POSSIBLE_OWNER, PciRes()->StrGroup(), PciRes()->StrOwner());
  893. AfxMessageBox(strMsg, MB_OK | MB_ICONSTOP);
  894. strMsg.Empty(); // prepare to throw exception in Fail()
  895. pDX->Fail();
  896. } // if: not owned by possible owner
  897. #endif
  898. } // if: Back button not pressed
  899. } // if: saving data from dialog
  900. } //*** CNewResOwnersPage::DoDataExchange()
  901. /////////////////////////////////////////////////////////////////////////////
  902. //++
  903. //
  904. // CNewResOwnersPage::BInitLists
  905. //
  906. // Routine Description:
  907. // Initialize the lists.
  908. //
  909. // Arguments:
  910. // None.
  911. //
  912. // Return Value:
  913. // TRUE Page initialized successfully.
  914. // FALSE Page failed to initialize.
  915. //
  916. //--
  917. /////////////////////////////////////////////////////////////////////////////
  918. BOOL CNewResOwnersPage::BInitLists(void)
  919. {
  920. BOOL bSuccess = TRUE;
  921. ASSERT_VALID(PciRes());
  922. try
  923. {
  924. SetLists(&PciRes()->LpcinodePossibleOwners(), &PciRes()->Pdoc()->LpciNodes());
  925. } // try
  926. catch (CException * pe)
  927. {
  928. pe->ReportError();
  929. pe->Delete();
  930. bSuccess = FALSE;
  931. } // catch: CException
  932. return bSuccess;
  933. } //*** CNewResOwnersPage::BInitLists()
  934. /////////////////////////////////////////////////////////////////////////////
  935. //++
  936. //
  937. // CNewResOwnersPage::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 CNewResOwnersPage::OnInitDialog(void)
  952. {
  953. // Add columns.
  954. try
  955. {
  956. NAddColumn(IDS_COLTEXT_NAME, COLI_WIDTH_NAME);
  957. } // try
  958. catch (CException * pe)
  959. {
  960. pe->ReportError();
  961. pe->Delete();
  962. } // catch: CException
  963. // Call the base class method.
  964. CListCtrlPairWizPage::OnInitDialog();
  965. return TRUE; // return TRUE unless you set the focus to a control
  966. // EXCEPTION: OCX Property Pages should return FALSE
  967. } //*** CNewResOwnersPage::OnInitDialog()
  968. /////////////////////////////////////////////////////////////////////////////
  969. //++
  970. //
  971. // CNewResOwnersPage::OnSetActive
  972. //
  973. // Routine Description:
  974. // Handler for the PSN_SETACTIVE message.
  975. //
  976. // Arguments:
  977. // None.
  978. //
  979. // Return Value:
  980. // TRUE Page successfully initialized.
  981. // FALSE Page not initialized.
  982. //
  983. //--
  984. /////////////////////////////////////////////////////////////////////////////
  985. BOOL CNewResOwnersPage::OnSetActive(void)
  986. {
  987. BOOL bSuccess;
  988. PciRes()->CollectPossibleOwners(NULL);
  989. bSuccess = CListCtrlPairWizPage::OnSetActive();
  990. return bSuccess;
  991. } //*** CNewResOwnersPage::OnSetActive()
  992. /////////////////////////////////////////////////////////////////////////////
  993. //++
  994. //
  995. // CNewResOwnersPage::BApplyChanges
  996. //
  997. // Routine Description:
  998. // Apply changes made on the page.
  999. //
  1000. // Arguments:
  1001. // None.
  1002. //
  1003. // Return Value:
  1004. // TRUE Page successfully applied.
  1005. // FALSE Error applying page.
  1006. //
  1007. //--
  1008. /////////////////////////////////////////////////////////////////////////////
  1009. BOOL CNewResOwnersPage::BApplyChanges(void)
  1010. {
  1011. CWaitCursor wc;
  1012. try
  1013. {
  1014. // Set the data from the page in the cluster item.
  1015. PciRes()->SetPossibleOwners((CNodeList &) Plcp()->LpobjRight());
  1016. } // try
  1017. catch (CException * pe)
  1018. {
  1019. pe->ReportError();
  1020. pe->Delete();
  1021. return FALSE;
  1022. } // catch: CException
  1023. return CListCtrlPairWizPage::BApplyChanges();
  1024. } //*** CNewResOwnersPage::BApplyChanges()
  1025. /////////////////////////////////////////////////////////////////////////////
  1026. //++
  1027. //
  1028. // CNewResOwnersPage::BOwnedByPossibleOwner
  1029. //
  1030. // Routine Description:
  1031. // Determine if the group in which this resource resides is owned by
  1032. // a node in the proposed possible owners list.
  1033. //
  1034. // Arguments:
  1035. // None.
  1036. //
  1037. // Return Value:
  1038. // TRUE Group owned by node in possible owners list.
  1039. // FALSE Group NOT owned by node in possible owners list.
  1040. //
  1041. // Exceptions Thrown:
  1042. //
  1043. //--
  1044. /////////////////////////////////////////////////////////////////////////////
  1045. BOOL CNewResOwnersPage::BOwnedByPossibleOwner(void) const
  1046. {
  1047. CClusterNode * pciNode = NULL;
  1048. // Get the node on which the resource is online.
  1049. PciRes()->UpdateState();
  1050. // Find the owner node in the proposed possible owners list.
  1051. {
  1052. POSITION pos;
  1053. pos = Plcp()->LpobjRight().GetHeadPosition();
  1054. while (pos != NULL)
  1055. {
  1056. pciNode = (CClusterNode *) Plcp()->LpobjRight().GetNext(pos);
  1057. ASSERT_VALID(pciNode);
  1058. if (PciRes()->StrOwner().CompareNoCase(pciNode->StrName()) == 0)
  1059. break;
  1060. pciNode = NULL;
  1061. } // while: more items in the list
  1062. } // Find the owner node in the proposed possible owners list
  1063. return (pciNode != NULL);
  1064. } //*** CNewResOwnersPage::BOwnedByPossibleOwner()
  1065. /////////////////////////////////////////////////////////////////////////////
  1066. //++
  1067. //
  1068. // CNewResOwnersPage::GetColumn [static]
  1069. //
  1070. // Routine Description:
  1071. // Returns a column for an item.
  1072. //
  1073. // Arguments:
  1074. // pobj [IN OUT] Object for which the column is to be displayed.
  1075. // iItem [IN] Index of the item in the list.
  1076. // icol [IN] Column number whose text is to be retrieved.
  1077. // pdlg [IN OUT] Dialog to which object belongs.
  1078. // rstr [OUT] String in which to return column text.
  1079. // piimg [OUT] Image index for the object.
  1080. //
  1081. // Return Value:
  1082. // None.
  1083. //
  1084. //--
  1085. /////////////////////////////////////////////////////////////////////////////
  1086. void CALLBACK CNewResOwnersPage::GetColumn(
  1087. IN OUT CObject * pobj,
  1088. IN int iItem,
  1089. IN int icol,
  1090. IN OUT CDialog * pdlg,
  1091. OUT CString & rstr,
  1092. OUT int * piimg
  1093. )
  1094. {
  1095. CClusterNode * pciNode = (CClusterNode *) pobj;
  1096. int colid;
  1097. ASSERT_VALID(pciNode);
  1098. ASSERT((0 <= icol) && (icol <= 1));
  1099. switch (icol)
  1100. {
  1101. // Sorting by resource name.
  1102. case 0:
  1103. colid = IDS_COLTEXT_NAME;
  1104. break;
  1105. default:
  1106. ASSERT(0);
  1107. colid = IDS_COLTEXT_NAME;
  1108. break;
  1109. } // switch: pdlg->NSortColumn()
  1110. pciNode->BGetColumnData(colid, rstr);
  1111. if (piimg != NULL)
  1112. *piimg = pciNode->IimgObjectType();
  1113. } //*** CNewResOwnersPage::GetColumn()
  1114. /////////////////////////////////////////////////////////////////////////////
  1115. //++
  1116. //
  1117. // CNewResOwnersPage::BDisplayProperties [static]
  1118. //
  1119. // Routine Description:
  1120. // Display the properties of the specified object.
  1121. //
  1122. // Arguments:
  1123. // pobj [IN OUT] Cluster item whose properties are to be displayed.
  1124. //
  1125. // Return Value:
  1126. // TRUE Properties where accepted.
  1127. // FALSE Properties where cancelled.
  1128. //
  1129. //--
  1130. /////////////////////////////////////////////////////////////////////////////
  1131. BOOL CALLBACK CNewResOwnersPage::BDisplayProperties(IN OUT CObject * pobj)
  1132. {
  1133. CClusterItem * pci = (CClusterItem *) pobj;
  1134. ASSERT_KINDOF(CClusterItem, pobj);
  1135. return pci->BDisplayProperties();
  1136. } //*** CNewResOwnersPage::BDisplayProperties();
  1137. //*************************************************************************//
  1138. /////////////////////////////////////////////////////////////////////////////
  1139. // CNewResDependsPage property page
  1140. /////////////////////////////////////////////////////////////////////////////
  1141. IMPLEMENT_DYNCREATE(CNewResDependsPage, CListCtrlPairWizPage)
  1142. /////////////////////////////////////////////////////////////////////////////
  1143. // Message Maps
  1144. /////////////////////////////////////////////////////////////////////////////
  1145. BEGIN_MESSAGE_MAP(CNewResDependsPage, CListCtrlPairWizPage)
  1146. //{{AFX_MSG_MAP(CNewResDependsPage)
  1147. //}}AFX_MSG_MAP
  1148. END_MESSAGE_MAP()
  1149. /////////////////////////////////////////////////////////////////////////////
  1150. //++
  1151. //
  1152. // CNewResDependsPage::CNewResDependsPage
  1153. //
  1154. // Routine Description:
  1155. // Constructor.
  1156. //
  1157. // Arguments:
  1158. // None.
  1159. //
  1160. // Return Value:
  1161. // None.
  1162. //
  1163. //--
  1164. /////////////////////////////////////////////////////////////////////////////
  1165. CNewResDependsPage::CNewResDependsPage(void)
  1166. : CListCtrlPairWizPage(
  1167. IDD,
  1168. g_aHelpIDs_IDD_WIZ_DEPENDENCIES,
  1169. LCPS_SHOW_IMAGES | LCPS_ALLOW_EMPTY,
  1170. GetColumn,
  1171. BDisplayProperties
  1172. )
  1173. {
  1174. //{{AFX_DATA_INIT(CNewResDependsPage)
  1175. //}}AFX_DATA_INIT
  1176. } //*** CNewResDependsPage::CNewResDependsPage()
  1177. /////////////////////////////////////////////////////////////////////////////
  1178. //++
  1179. //
  1180. // CNewResDependsPage::DoDataExchange
  1181. //
  1182. // Routine Description:
  1183. // Do data exchange between the dialog and the class.
  1184. //
  1185. // Arguments:
  1186. // pDX [IN OUT] Data exchange object
  1187. //
  1188. // Return Value:
  1189. // None.
  1190. //
  1191. //--
  1192. /////////////////////////////////////////////////////////////////////////////
  1193. void CNewResDependsPage::DoDataExchange(CDataExchange * pDX)
  1194. {
  1195. // Initialize the lists before the list pair control is updated.
  1196. if (!pDX->m_bSaveAndValidate)
  1197. {
  1198. if (!BInitLists())
  1199. pDX->Fail();
  1200. } // if: setting data to the dialog
  1201. CListCtrlPairWizPage::DoDataExchange(pDX);
  1202. //{{AFX_DATA_MAP(CNewResDependsPage)
  1203. //}}AFX_DATA_MAP
  1204. } //*** CNewResDependsPage::DoDataExchange()
  1205. /////////////////////////////////////////////////////////////////////////////
  1206. //++
  1207. //
  1208. // CNewResDependsPage::BInitLists
  1209. //
  1210. // Routine Description:
  1211. // Initialize the lists.
  1212. //
  1213. // Arguments:
  1214. // None.
  1215. //
  1216. // Return Value:
  1217. // TRUE Page initialized successfully.
  1218. // FALSE Page failed to initialize.
  1219. //
  1220. //--
  1221. /////////////////////////////////////////////////////////////////////////////
  1222. BOOL CNewResDependsPage::BInitLists(void)
  1223. {
  1224. BOOL bSuccess = TRUE;
  1225. ASSERT_VALID(PciRes());
  1226. try
  1227. {
  1228. // Create the list of resources on which this resource can be dependent.
  1229. {
  1230. POSITION posPci;
  1231. CResource * pciRes;
  1232. const CResourceList & rlpciResources = PciGroup()->Lpcires();
  1233. LpciresAvailable().RemoveAll();
  1234. posPci = rlpciResources.GetHeadPosition();
  1235. while (posPci != NULL)
  1236. {
  1237. // Get the cluster item pointer.
  1238. pciRes = (CResource *) rlpciResources.GetNext(posPci);
  1239. ASSERT_VALID(pciRes);
  1240. // If we CAN be dependent on this resource, add it to our Available list.
  1241. if (PciRes()->BCanBeDependent(pciRes)
  1242. || PciRes()->BIsDependent(pciRes))
  1243. LpciresAvailable().AddTail(pciRes);
  1244. } // while: more items in the list
  1245. } // Create the list of resources on which this resource can be dependent
  1246. SetLists(&PciRes()->LpciresDependencies(), &LpciresAvailable());
  1247. } // try
  1248. catch (CException * pe)
  1249. {
  1250. pe->ReportError();
  1251. pe->Delete();
  1252. bSuccess = FALSE;
  1253. } // catch: CException
  1254. return bSuccess;
  1255. } //*** CNewResDependsPage::BInitLists()
  1256. /////////////////////////////////////////////////////////////////////////////
  1257. //++
  1258. //
  1259. // CNewResDependsPage::OnInitDialog
  1260. //
  1261. // Routine Description:
  1262. // Handler for the WM_INITDIALOG message.
  1263. //
  1264. // Arguments:
  1265. // None.
  1266. //
  1267. // Return Value:
  1268. // TRUE Focus needs to be set.
  1269. // FALSE Focus already set.
  1270. //
  1271. //--
  1272. /////////////////////////////////////////////////////////////////////////////
  1273. BOOL CNewResDependsPage::OnInitDialog(void)
  1274. {
  1275. // Add columns.
  1276. try
  1277. {
  1278. NAddColumn(IDS_COLTEXT_RESOURCE, COLI_WIDTH_NAME);
  1279. NAddColumn(IDS_COLTEXT_RESTYPE, COLI_WIDTH_RESTYPE);
  1280. } // try
  1281. catch (CException * pe)
  1282. {
  1283. pe->ReportError();
  1284. pe->Delete();
  1285. } // catch: CException
  1286. // Call the base class method.
  1287. CListCtrlPairWizPage::OnInitDialog();
  1288. return TRUE; // return TRUE unless you set the focus to a control
  1289. // EXCEPTION: OCX Property Pages should return FALSE
  1290. } //*** CNewResDependsPage::OnInitDialog()
  1291. /////////////////////////////////////////////////////////////////////////////
  1292. //++
  1293. //
  1294. // CNewResDependsPage::BApplyChanges
  1295. //
  1296. // Routine Description:
  1297. // Apply changes made on the page.
  1298. //
  1299. // Arguments:
  1300. // None.
  1301. //
  1302. // Return Value:
  1303. // TRUE Page successfully applied.
  1304. // FALSE Error applying page.
  1305. //
  1306. //--
  1307. /////////////////////////////////////////////////////////////////////////////
  1308. BOOL CNewResDependsPage::BApplyChanges(void)
  1309. {
  1310. CWaitCursor wc;
  1311. // Check to see if required dependencies have been made.
  1312. {
  1313. CString strMissing;
  1314. CString strMsg;
  1315. try
  1316. {
  1317. if (!PciRes()->BRequiredDependenciesPresent((const CResourceList &)Plcp()->LpobjRight(), strMissing))
  1318. {
  1319. strMsg.FormatMessage(IDS_REQUIRED_DEPENDENCY_NOT_FOUND, strMissing);
  1320. AfxMessageBox(strMsg, MB_OK | MB_ICONSTOP);
  1321. return FALSE;
  1322. } // if: all required dependencies not present
  1323. } // try
  1324. catch (CException * pe)
  1325. {
  1326. pe->ReportError();
  1327. pe->Delete();
  1328. return FALSE;
  1329. } // catch: CException
  1330. } // Check to see if required dependencies have been made
  1331. // Set the data from the page in the cluster item.
  1332. try
  1333. {
  1334. PciRes()->SetDependencies((CResourceList &) Plcp()->LpobjRight());
  1335. } // try
  1336. catch (CException * pe)
  1337. {
  1338. pe->ReportError();
  1339. pe->Delete();
  1340. return FALSE;
  1341. } // catch: CException
  1342. return CListCtrlPairWizPage::BApplyChanges();
  1343. } //*** CNewResDependsPage::BApplyChanges()
  1344. /////////////////////////////////////////////////////////////////////////////
  1345. //++
  1346. //
  1347. // CNewResDependsPage::GetColumn [static]
  1348. //
  1349. // Routine Description:
  1350. // Returns a column for an item.
  1351. //
  1352. // Arguments:
  1353. // pobj [IN OUT] Object for which the column is to be displayed.
  1354. // iItem [IN] Index of the item in the list.
  1355. // icol [IN] Column number whose text is to be retrieved.
  1356. // pdlg [IN OUT] Dialog to which object belongs.
  1357. // rstr [OUT] String in which to return column text.
  1358. // piimg [OUT] Image index for the object.
  1359. //
  1360. // Return Value:
  1361. // None.
  1362. //
  1363. //--
  1364. /////////////////////////////////////////////////////////////////////////////
  1365. void CALLBACK CNewResDependsPage::GetColumn(
  1366. IN OUT CObject * pobj,
  1367. IN int iItem,
  1368. IN int icol,
  1369. IN OUT CDialog * pdlg,
  1370. OUT CString & rstr,
  1371. OUT int * piimg
  1372. )
  1373. {
  1374. CResource * pciRes = (CResource *) pobj;
  1375. int colid;
  1376. ASSERT_VALID(pciRes);
  1377. ASSERT((0 <= icol) && (icol <= 1));
  1378. switch (icol)
  1379. {
  1380. // Sorting by resource name.
  1381. case 0:
  1382. colid = IDS_COLTEXT_RESOURCE;
  1383. break;
  1384. // Sorting by resource type.
  1385. case 1:
  1386. colid = IDS_COLTEXT_RESTYPE;
  1387. break;
  1388. default:
  1389. ASSERT(0);
  1390. colid = IDS_COLTEXT_RESOURCE;
  1391. break;
  1392. } // switch: pdlg->NSortColumn()
  1393. pciRes->BGetColumnData(colid, rstr);
  1394. if (piimg != NULL)
  1395. *piimg = pciRes->IimgObjectType();
  1396. } //*** CNewResDependsPage::GetColumn()
  1397. /////////////////////////////////////////////////////////////////////////////
  1398. //++
  1399. //
  1400. // CNewResDependsPage::BDisplayProperties [static]
  1401. //
  1402. // Routine Description:
  1403. // Display the properties of the specified object.
  1404. //
  1405. // Arguments:
  1406. // pobj [IN OUT] Cluster item whose properties are to be displayed.
  1407. //
  1408. // Return Value:
  1409. // TRUE Properties where accepted.
  1410. // FALSE Properties where cancelled.
  1411. //
  1412. //--
  1413. /////////////////////////////////////////////////////////////////////////////
  1414. BOOL CALLBACK CNewResDependsPage::BDisplayProperties(IN OUT CObject * pobj)
  1415. {
  1416. CClusterItem * pci = (CClusterItem *) pobj;
  1417. ASSERT_KINDOF(CClusterItem, pobj);
  1418. return pci->BDisplayProperties();
  1419. } //*** CNewResDependsPage::BDisplayProperties();