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.

3318 lines
81 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. scopewiz.cpp
  7. DHCP scope creation dialog
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "server.h"
  12. #include "scopewiz.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. #define MASK_MIN 1
  19. #define MASK_MAX 31
  20. #define SCOPE_WARNING_COUNT 20
  21. int CScopeWizLeaseTime::m_nDaysDefault = SCOPE_DFAULT_LEASE_DAYS;
  22. int CScopeWizLeaseTime::m_nHoursDefault = SCOPE_DFAULT_LEASE_HOURS;
  23. int CScopeWizLeaseTime::m_nMinutesDefault = SCOPE_DFAULT_LEASE_MINUTES;
  24. /////////////////////////////////////////////////////////////////////////////
  25. //
  26. // CScopeWiz holder
  27. //
  28. /////////////////////////////////////////////////////////////////////////////
  29. CScopeWiz::CScopeWiz
  30. (
  31. ITFSNode * pNode,
  32. IComponentData * pComponentData,
  33. ITFSComponentData * pTFSCompData,
  34. LPCTSTR pSuperscopeName,
  35. LPCTSTR pszSheetName
  36. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  37. {
  38. //ASSERT(pFolderNode == GetContainerNode());
  39. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  40. AddPageToList((CPropertyPageBase*) &m_pageWelcome);
  41. AddPageToList((CPropertyPageBase*) &m_pageName);
  42. AddPageToList((CPropertyPageBase*) &m_pageInvalidName);
  43. AddPageToList((CPropertyPageBase*) &m_pageSetRange);
  44. AddPageToList((CPropertyPageBase*) &m_pageSetExclusions);
  45. AddPageToList((CPropertyPageBase*) &m_pageLeaseTime);
  46. AddPageToList((CPropertyPageBase*) &m_pageCreateSuperscope);
  47. AddPageToList((CPropertyPageBase*) &m_pageConfigOptions);
  48. AddPageToList((CPropertyPageBase*) &m_pageRouter);
  49. AddPageToList((CPropertyPageBase*) &m_pageDNS);
  50. AddPageToList((CPropertyPageBase*) &m_pageWINS);
  51. AddPageToList((CPropertyPageBase*) &m_pageActivate);
  52. AddPageToList((CPropertyPageBase*) &m_pageFinished);
  53. Assert(pTFSCompData != NULL);
  54. m_spTFSCompData.Set(pTFSCompData);
  55. m_strSuperscopeName = pSuperscopeName;
  56. m_fCreateSuperscope = FALSE;
  57. m_fOptionsConfigured = FALSE;
  58. m_fActivateScope = FALSE;
  59. m_pDefaultOptions = NULL;
  60. m_poptDomainName = NULL;
  61. m_poptDNSServers = NULL;
  62. m_poptRouters = NULL;
  63. m_poptWINSNodeType = NULL;
  64. m_poptWINSServers = NULL;
  65. m_bWiz97 = TRUE;
  66. m_spTFSCompData->SetWatermarkInfo(&g_WatermarkInfoScope);
  67. }
  68. CScopeWiz::~CScopeWiz()
  69. {
  70. RemovePageFromList((CPropertyPageBase*) &m_pageName, FALSE);
  71. RemovePageFromList((CPropertyPageBase*) &m_pageInvalidName, FALSE);
  72. RemovePageFromList((CPropertyPageBase*) &m_pageSetRange, FALSE);
  73. RemovePageFromList((CPropertyPageBase*) &m_pageSetExclusions, FALSE);
  74. RemovePageFromList((CPropertyPageBase*) &m_pageLeaseTime, FALSE);
  75. RemovePageFromList((CPropertyPageBase*) &m_pageCreateSuperscope, FALSE);
  76. RemovePageFromList((CPropertyPageBase*) &m_pageConfigOptions, FALSE);
  77. RemovePageFromList((CPropertyPageBase*) &m_pageRouter, FALSE);
  78. RemovePageFromList((CPropertyPageBase*) &m_pageDNS, FALSE);
  79. RemovePageFromList((CPropertyPageBase*) &m_pageWINS, FALSE);
  80. RemovePageFromList((CPropertyPageBase*) &m_pageActivate, FALSE);
  81. RemovePageFromList((CPropertyPageBase*) &m_pageFinished, FALSE);
  82. }
  83. //
  84. // Called from the OnWizardFinish to add the DHCP Server to the list
  85. //
  86. DWORD
  87. CScopeWiz::OnFinish()
  88. {
  89. if (m_fCreateSuperscope)
  90. {
  91. return CreateSuperscope();
  92. }
  93. else
  94. {
  95. return CreateScope();
  96. }
  97. }
  98. BOOL
  99. CScopeWiz::GetScopeRange(CDhcpIpRange * pdhcpIpRange)
  100. {
  101. return m_pageSetRange.GetScopeRange(pdhcpIpRange);
  102. }
  103. DWORD
  104. CScopeWiz::CreateSuperscope()
  105. {
  106. LONG err = 0;
  107. LONG dwErrReturn = 0;
  108. BOOL fScopeCreated = FALSE;
  109. BOOL fFinished = FALSE;
  110. DHCP_IP_ADDRESS dhcpSubnetId ;
  111. DHCP_IP_ADDRESS dhcpSubnetMask ;
  112. CDhcpScope * pobScope = NULL ;
  113. CDhcpIpRange dhcpIpRange;
  114. CDhcpServer * pServer;
  115. SPITFSNode spServerNode, spSuperscopeNode;
  116. CString strSuperscopeTemplate = _T("Superscope %d");
  117. CString strSuperscopeName;
  118. CString strFinishText;
  119. int nSuperscopeSuffix = 0;
  120. int nScopesCreated = 0;
  121. int nScopesTotal = 0;
  122. SPITFSComponentData spTFSCompData;
  123. SPITFSNodeMgr spNodeMgr;
  124. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  125. // Get the server node depending upon how we were called
  126. if (m_strSuperscopeName.IsEmpty())
  127. {
  128. spServerNode = GetNode();
  129. }
  130. else
  131. {
  132. SPITFSNode spSscopeNode;
  133. spSscopeNode = GetNode();
  134. spSscopeNode->GetParent(&spServerNode);
  135. }
  136. spServerNode->GetNodeMgr(&spNodeMgr);
  137. spTFSCompData = GetTFSCompData();
  138. // setup some necessary things for the superscope object for the UI
  139. CDhcpSuperscope * pSuperscope = new CDhcpSuperscope(spTFSCompData);
  140. pSuperscope->SetServer(spServerNode);
  141. // find a superscope name that doesn't already exist
  142. strSuperscopeName.Format(strSuperscopeTemplate, nSuperscopeSuffix);
  143. while (pSuperscope->DoesSuperscopeExist(strSuperscopeName))
  144. {
  145. nSuperscopeSuffix++;
  146. strSuperscopeName.Format(strSuperscopeTemplate, nSuperscopeSuffix);
  147. }
  148. // Set the new name in the superscope object
  149. pSuperscope->SetName(strSuperscopeName);
  150. CreateContainerTFSNode(&spSuperscopeNode,
  151. &GUID_DhcpSuperscopeNodeType,
  152. pSuperscope,
  153. pSuperscope,
  154. spNodeMgr);
  155. // Tell the handler to initialize any specific data
  156. if (m_fOptionsConfigured && m_fActivateScope)
  157. pSuperscope->SetState(DhcpSubnetEnabled);
  158. pSuperscope->InitializeNode((ITFSNode *) spSuperscopeNode);
  159. pServer = GETHANDLER(CDhcpServer, spServerNode);
  160. // Ok, now the fun begins...
  161. CDhcpIpRange ipRangeTotal, ipRangeCurrent;
  162. m_pageSetRange.GetScopeRange(&ipRangeTotal);
  163. dhcpSubnetMask = m_pageSetRange.GetSubnetMask();
  164. // Set the start address for the first scope
  165. ipRangeCurrent.SetAddr(ipRangeTotal.QueryAddr(TRUE), TRUE);
  166. while (!fFinished)
  167. {
  168. SPITFSNode spNode;
  169. nScopesTotal++;
  170. // Calculate the subnet ID
  171. dhcpSubnetId = ipRangeCurrent.QueryAddr(TRUE) & dhcpSubnetMask;
  172. // 0 is an invalid start address for a range. Check to make sure
  173. // that the starting address of the range isn't 0, if it is, then add 1
  174. DWORD startAddr = ipRangeCurrent.QueryAddr(TRUE);
  175. if ((startAddr & ~dhcpSubnetMask) == 0)
  176. {
  177. ipRangeCurrent.SetAddr(startAddr+1, TRUE);
  178. }
  179. // set the ending address of the (subnetId + ~subnetmask) - 1. Just adding the subnet
  180. // mask gives us the broadcast address for that subnet. We don't want that!
  181. ipRangeCurrent.SetAddr((dhcpSubnetId + ~dhcpSubnetMask) - 1, FALSE);
  182. // check to see if we are at the last scope, if so make sure we don't
  183. // go over what the range the user specified and set the flag so we'll quit
  184. if (ipRangeCurrent.QueryAddr(FALSE) >= ipRangeTotal.QueryAddr(FALSE))
  185. {
  186. // set the ending address to what the user specified
  187. ipRangeCurrent.SetAddr(ipRangeTotal.QueryAddr(FALSE), FALSE);
  188. fFinished = TRUE;
  189. }
  190. // Create the scope on the server and then we can
  191. // create our internal object.
  192. err = pServer->CreateScope(dhcpSubnetId,
  193. dhcpSubnetMask,
  194. m_pageName.m_strName,
  195. m_pageName.m_strComment);
  196. if (err != ERROR_SUCCESS)
  197. {
  198. Trace1("CScopeWiz::CreateScope() - Couldn't create scope! Error = %d\n", err);
  199. dwErrReturn = err;
  200. // increment the scope address by 2. +1 gets us the network broadcast address,
  201. // the next +1 gets us to the next subnet.
  202. ipRangeCurrent.SetAddr(ipRangeCurrent.QueryAddr(FALSE) + 2, TRUE);
  203. continue;
  204. }
  205. // now create our object that represents the scope for the UI
  206. pobScope = new CDhcpScope(spTFSCompData,
  207. dhcpSubnetId,
  208. dhcpSubnetMask,
  209. m_pageName.m_strName,
  210. m_pageName.m_strComment);
  211. if ( pobScope == NULL )
  212. {
  213. err = ERROR_NOT_ENOUGH_MEMORY ;
  214. break ;
  215. }
  216. // Store the server object in the holder
  217. CreateContainerTFSNode(&spNode,
  218. &GUID_DhcpScopeNodeType,
  219. pobScope,
  220. pobScope,
  221. spNodeMgr);
  222. // Tell the handler to initialize any specific data
  223. pobScope->SetServer(spServerNode);
  224. pobScope->InitializeNode((ITFSNode *) spNode);
  225. pobScope->Release();
  226. // Finish creating the scope. First, the IP address range
  227. // from which to allocate addresses.
  228. if ( err = pobScope->SetIpRange( ipRangeCurrent, TRUE ) )
  229. {
  230. Trace2("SetIpRange on scope %lx failed!! %d\n", dhcpSubnetId, err);
  231. dwErrReturn = err;
  232. pServer->DeleteSubnet(pobScope->GetAddress());
  233. goto Cleanup;
  234. }
  235. // set the lease time
  236. DWORD dwLeaseTime;
  237. dwLeaseTime = m_pageLeaseTime.GetLeaseTime();
  238. err = pobScope->SetLeaseTime(dwLeaseTime);
  239. if (err != ERROR_SUCCESS)
  240. {
  241. Trace2("SetLeaseTime on Scope %lx failed!! %d\n", dhcpSubnetId, err);
  242. dwErrReturn = err;
  243. pServer->DeleteSubnet(pobScope->GetAddress());
  244. goto Cleanup;
  245. }
  246. // Set this scope as part of the superscope
  247. err = pobScope->SetSuperscope(strSuperscopeName, FALSE);
  248. if (err != ERROR_SUCCESS)
  249. {
  250. Trace2("SetSuperscope on scope %lx failed!! %d\n", dhcpSubnetId, err);
  251. dwErrReturn = err;
  252. pServer->DeleteSubnet(pobScope->GetAddress());
  253. goto Cleanup;
  254. }
  255. pobScope->SetInSuperscope(TRUE);
  256. // now set any optional options the user may want
  257. if (m_fOptionsConfigured)
  258. {
  259. err = SetScopeOptions(pobScope);
  260. if (err != ERROR_SUCCESS)
  261. {
  262. Trace1("SetScopeOptions failed!! %d\n", err);
  263. break;
  264. }
  265. }
  266. // increment our counter
  267. nScopesCreated++;
  268. // cleanup this node and handler... they were only temporary
  269. Cleanup:
  270. // we add two to the ending address to get the next starting address. This
  271. // is because the ending adddress is one less than the maximum address for the
  272. // subnet. The maximum address is reserved as the broadcast address. So to get
  273. // the starting address of the next subnet we add one to get us to the broadcast
  274. // address, and one more to get us to the beginning of the next subnet.
  275. // This gives us a total of 2.
  276. ipRangeCurrent.SetAddr(ipRangeCurrent.QueryAddr(FALSE) + 2, TRUE);
  277. spNode->DeleteAllChildren(FALSE);
  278. spNode->Destroy();
  279. }
  280. pSuperscope->Release();
  281. // let the user know how many scopes were created and if there was an error;
  282. CString strTemp;
  283. if (nScopesCreated == 0)
  284. {
  285. strFinishText.LoadString(IDS_SUPERSCOPE_CREATE_FAILED);
  286. }
  287. else
  288. if (nScopesCreated < nScopesTotal)
  289. {
  290. strTemp.LoadString(IDS_SUPERSCOPE_CREATE_STATUS);
  291. strFinishText.Format(strTemp, strSuperscopeName, nScopesCreated, nScopesTotal);
  292. }
  293. if (dwErrReturn != ERROR_SUCCESS)
  294. {
  295. LPTSTR pBuf;
  296. strFinishText += _T("\n\n");
  297. strTemp.LoadString(IDS_POSSIBLE_ERROR);
  298. strFinishText += strTemp;
  299. pBuf = strTemp.GetBuffer(4000);
  300. ::LoadMessage(dwErrReturn, pBuf, 4000);
  301. strTemp.ReleaseBuffer();
  302. strFinishText += strTemp;
  303. }
  304. if (nScopesCreated)
  305. {
  306. // add the superscope to the UI
  307. pServer->AddSuperscopeSorted(spServerNode, spSuperscopeNode);
  308. }
  309. if (!strFinishText.IsEmpty())
  310. AfxMessageBox(strFinishText);
  311. return ERROR_SUCCESS;
  312. }
  313. DWORD
  314. CScopeWiz::CreateScope()
  315. {
  316. LONG err = 0,
  317. err2 ;
  318. BOOL fScopeCreated = FALSE;
  319. DHCP_IP_ADDRESS dhcpSubnetId ;
  320. DHCP_IP_ADDRESS dhcpSubnetMask ;
  321. CDhcpScope * pobScope = NULL ;
  322. CDhcpIpRange dhcpIpRange;
  323. CDhcpServer * pServer;
  324. SPITFSNode spNode, spServerNode, spSuperscopeNode;
  325. // Get the correct node depending up how the wizard was launched
  326. // ie. either from the Server node or the superscope node.
  327. if (m_strSuperscopeName.IsEmpty())
  328. {
  329. spServerNode = GetNode();
  330. }
  331. else
  332. {
  333. spSuperscopeNode = GetNode();
  334. spSuperscopeNode->GetParent(&spServerNode);
  335. }
  336. do
  337. {
  338. pServer = GETHANDLER(CDhcpServer, spServerNode);
  339. //
  340. // Create the scope on the server and then we can
  341. // create our internal object.
  342. //
  343. dhcpSubnetId = m_pageSetRange.DetermineSubnetId(TRUE);
  344. dhcpSubnetMask = m_pageSetRange.GetSubnetMask();
  345. err = pServer->CreateScope(dhcpSubnetId,
  346. dhcpSubnetMask,
  347. m_pageName.m_strName,
  348. m_pageName.m_strComment);
  349. if (err != 0)
  350. {
  351. Trace1("CScopeWiz::CreateScope() - Couldn't create scope! Error = %d\n", err);
  352. break;
  353. }
  354. SPITFSComponentData spTFSCompData;
  355. spTFSCompData = GetTFSCompData();
  356. pobScope = new CDhcpScope(spTFSCompData,
  357. dhcpSubnetId,
  358. dhcpSubnetMask,
  359. m_pageName.m_strName,
  360. m_pageName.m_strComment);
  361. if ( pobScope == NULL )
  362. {
  363. err = ERROR_NOT_ENOUGH_MEMORY ;
  364. break ;
  365. }
  366. SPITFSNodeMgr spNodeMgr;
  367. spServerNode->GetNodeMgr(&spNodeMgr);
  368. //
  369. // Store the server object in the holder
  370. //
  371. CreateContainerTFSNode(&spNode,
  372. &GUID_DhcpServerNodeType,
  373. pobScope,
  374. pobScope,
  375. spNodeMgr);
  376. // Tell the handler to initialize any specific data
  377. pobScope->SetServer(spServerNode);
  378. pobScope->InitializeNode((ITFSNode *) spNode);
  379. if (m_strSuperscopeName.IsEmpty())
  380. {
  381. CDhcpServer * pServer1 = GETHANDLER(CDhcpServer, spServerNode);
  382. pServer1->AddScopeSorted(spServerNode, spNode);
  383. }
  384. else
  385. {
  386. CDhcpSuperscope * pSuperscope = GETHANDLER(CDhcpSuperscope, spSuperscopeNode);
  387. pSuperscope->AddScopeSorted(spSuperscopeNode, spNode);
  388. }
  389. pobScope->Release();
  390. fScopeCreated = TRUE;
  391. //
  392. // Finish updating the scope. First, the IP address range
  393. // from which to allocate addresses.
  394. //
  395. m_pageSetRange.GetScopeRange(&dhcpIpRange);
  396. if ( err = pobScope->SetIpRange( dhcpIpRange, TRUE ) )
  397. {
  398. Trace1("SetIpRange failed!! %d\n", err);
  399. break ;
  400. }
  401. //
  402. // Next, see if any exclusions were specified.
  403. //
  404. err = pobScope->StoreExceptionList( m_pageSetExclusions.GetExclusionList() ) ;
  405. if (err != ERROR_SUCCESS)
  406. {
  407. Trace1("StoreExceptionList failed!! %d\n", err);
  408. break;
  409. }
  410. //
  411. // set the lease time
  412. //
  413. DWORD dwLeaseTime;
  414. dwLeaseTime = m_pageLeaseTime.GetLeaseTime();
  415. err = pobScope->SetLeaseTime(dwLeaseTime);
  416. if (err != ERROR_SUCCESS)
  417. {
  418. Trace1("SetLeaseTime failed!! %d\n", err);
  419. break;
  420. }
  421. if (!m_strSuperscopeName.IsEmpty())
  422. {
  423. // Set this scope as part of the superscope
  424. err = pobScope->SetSuperscope(m_strSuperscopeName, FALSE);
  425. if (err != ERROR_SUCCESS)
  426. {
  427. Trace1("SetSuperscope failed!! %d\n", err);
  428. break;
  429. }
  430. }
  431. // now set any optional options the user may want
  432. if (m_fOptionsConfigured)
  433. {
  434. err = SetScopeOptions(pobScope);
  435. if (err != ERROR_SUCCESS)
  436. {
  437. Trace1("SetScopeOptions failed!! %d\n", err);
  438. break;
  439. }
  440. if (m_fActivateScope)
  441. {
  442. // update the icon
  443. spNode->SetData(TFS_DATA_IMAGEINDEX, pobScope->GetImageIndex(FALSE));
  444. spNode->SetData(TFS_DATA_OPENIMAGEINDEX, pobScope->GetImageIndex(TRUE));
  445. spNode->ChangeNode(SCOPE_PANE_CHANGE_ITEM_ICON);
  446. }
  447. }
  448. }
  449. while ( FALSE ) ;
  450. if ( err )
  451. {
  452. //
  453. // CODEWORK:: The scope should never have been added
  454. // to the remote registry in the first place.
  455. //
  456. if (pobScope != NULL)
  457. {
  458. if (fScopeCreated)
  459. {
  460. Trace0("Bad scope nevertheless was created\n");
  461. err2 = pServer->DeleteSubnet(pobScope->GetAddress());
  462. if (err2 != ERROR_SUCCESS)
  463. {
  464. Trace1("Couldn't remove the bad scope! Error = %d\n", err2);
  465. }
  466. }
  467. if (m_strSuperscopeName.IsEmpty())
  468. {
  469. spServerNode->RemoveChild(spNode);
  470. }
  471. else
  472. {
  473. spSuperscopeNode->RemoveChild(spNode);
  474. }
  475. }
  476. }
  477. return err;
  478. }
  479. DWORD
  480. CScopeWiz::SetScopeOptions(CDhcpScope * pScope)
  481. {
  482. DWORD dwErr = ERROR_SUCCESS;
  483. if (m_poptRouters)
  484. {
  485. dwErr = pScope->SetOptionValue(m_poptRouters, DhcpSubnetOptions);
  486. if (dwErr)
  487. return dwErr;
  488. }
  489. if (m_poptDomainName)
  490. {
  491. dwErr = pScope->SetOptionValue(m_poptDomainName, DhcpSubnetOptions);
  492. if (dwErr)
  493. return dwErr;
  494. }
  495. if (m_poptDNSServers)
  496. {
  497. dwErr = pScope->SetOptionValue(m_poptDNSServers, DhcpSubnetOptions);
  498. if (dwErr)
  499. return dwErr;
  500. }
  501. if (m_poptWINSServers)
  502. {
  503. dwErr = pScope->SetOptionValue(m_poptWINSServers, DhcpSubnetOptions);
  504. if (dwErr)
  505. return dwErr;
  506. }
  507. if (m_poptWINSNodeType)
  508. {
  509. dwErr = pScope->SetOptionValue(m_poptWINSNodeType, DhcpSubnetOptions);
  510. if (dwErr)
  511. return dwErr;
  512. }
  513. if (m_fActivateScope)
  514. {
  515. pScope->SetState(DhcpSubnetEnabled);
  516. dwErr = pScope->SetInfo();
  517. }
  518. return dwErr;
  519. }
  520. /////////////////////////////////////////////////////////////////////////////
  521. //
  522. // CScopeWizName property page
  523. //
  524. /////////////////////////////////////////////////////////////////////////////
  525. IMPLEMENT_DYNCREATE(CScopeWizName, CPropertyPageBase)
  526. CScopeWizName::CScopeWizName() : CPropertyPageBase(CScopeWizName::IDD)
  527. {
  528. //{{AFX_DATA_INIT(CScopeWizName)
  529. m_strName = _T("");
  530. m_strComment = _T("");
  531. //}}AFX_DATA_INIT
  532. InitWiz97(FALSE, IDS_SCOPE_WIZ_NAME_TITLE, IDS_SCOPE_WIZ_NAME_SUBTITLE);
  533. }
  534. CScopeWizName::~CScopeWizName()
  535. {
  536. }
  537. void CScopeWizName::DoDataExchange(CDataExchange* pDX)
  538. {
  539. CPropertyPageBase::DoDataExchange(pDX);
  540. //{{AFX_DATA_MAP(CScopeWizName)
  541. DDX_Control(pDX, IDC_EDIT_SCOPE_NAME, m_editScopeName);
  542. DDX_Control(pDX, IDC_EDIT_SCOPE_COMMENT, m_editScopeComment);
  543. DDX_Text(pDX, IDC_EDIT_SCOPE_NAME, m_strName);
  544. DDX_Text(pDX, IDC_EDIT_SCOPE_COMMENT, m_strComment);
  545. //}}AFX_DATA_MAP
  546. }
  547. BEGIN_MESSAGE_MAP(CScopeWizName, CPropertyPageBase)
  548. //{{AFX_MSG_MAP(CScopeWizName)
  549. ON_EN_CHANGE(IDC_EDIT_SCOPE_NAME, OnChangeEditScopeName)
  550. //}}AFX_MSG_MAP
  551. END_MESSAGE_MAP()
  552. /////////////////////////////////////////////////////////////////////////////
  553. //
  554. // CScopeWizName message handlers
  555. //
  556. /////////////////////////////////////////////////////////////////////////////
  557. BOOL CScopeWizName::OnInitDialog()
  558. {
  559. CPropertyPageBase::OnInitDialog();
  560. return TRUE; // return TRUE unless you set the focus to a control
  561. // EXCEPTION: OCX Property Pages should return FALSE
  562. }
  563. LRESULT CScopeWizName::OnWizardNext()
  564. {
  565. UpdateData();
  566. return IDW_SCOPE_SET_SCOPE;
  567. }
  568. BOOL CScopeWizName::OnSetActive()
  569. {
  570. UpdateButtons();
  571. return CPropertyPageBase::OnSetActive();
  572. }
  573. void CScopeWizName::OnChangeEditScopeName()
  574. {
  575. UpdateButtons();
  576. }
  577. /////////////////////////////////////////////////////////////////////////////
  578. //
  579. // CScopeWizName implementation specific
  580. //
  581. /////////////////////////////////////////////////////////////////////////////
  582. void
  583. CScopeWizName::UpdateButtons()
  584. {
  585. BOOL bValid = FALSE;
  586. UpdateData();
  587. if (m_strName.GetLength() > 0)
  588. bValid = TRUE;
  589. GetHolder()->SetWizardButtonsMiddle(bValid);
  590. }
  591. /////////////////////////////////////////////////////////////////////////////
  592. //
  593. // CScopeWizInvalidName property page
  594. //
  595. /////////////////////////////////////////////////////////////////////////////
  596. IMPLEMENT_DYNCREATE(CScopeWizInvalidName, CPropertyPageBase)
  597. CScopeWizInvalidName::CScopeWizInvalidName() : CPropertyPageBase(CScopeWizInvalidName::IDD)
  598. {
  599. //{{AFX_DATA_INIT(CScopeWizInvalidName)
  600. // NOTE: the ClassWizard will add member initialization here
  601. //}}AFX_DATA_INIT
  602. InitWiz97(FALSE, IDS_SCOPE_WIZ_INVALID_NAME_TITLE, IDS_SCOPE_WIZ_INVALID_NAME_SUBTITLE);
  603. }
  604. CScopeWizInvalidName::~CScopeWizInvalidName()
  605. {
  606. }
  607. void CScopeWizInvalidName::DoDataExchange(CDataExchange* pDX)
  608. {
  609. CPropertyPageBase::DoDataExchange(pDX);
  610. //{{AFX_DATA_MAP(CScopeWizInvalidName)
  611. // NOTE: the ClassWizard will add DDX and DDV calls here
  612. //}}AFX_DATA_MAP
  613. }
  614. BEGIN_MESSAGE_MAP(CScopeWizInvalidName, CPropertyPageBase)
  615. //{{AFX_MSG_MAP(CScopeWizInvalidName)
  616. // NOTE: the ClassWizard will add message map macros here
  617. //}}AFX_MSG_MAP
  618. END_MESSAGE_MAP()
  619. /////////////////////////////////////////////////////////////////////////////
  620. //
  621. // CScopeWizInvalidName message handlers
  622. //
  623. /////////////////////////////////////////////////////////////////////////////
  624. BOOL CScopeWizInvalidName::OnInitDialog()
  625. {
  626. CPropertyPageBase::OnInitDialog();
  627. return TRUE; // return TRUE unless you set the focus to a control
  628. // EXCEPTION: OCX Property Pages should return FALSE
  629. }
  630. LRESULT CScopeWizInvalidName::OnWizardBack()
  631. {
  632. // TODO: Add your specialized code here and/or call the base class
  633. return IDW_SCOPE_NAME;
  634. }
  635. BOOL CScopeWizInvalidName::OnSetActive()
  636. {
  637. GetHolder()->SetWizardButtonsLast(FALSE);
  638. return CPropertyPageBase::OnSetActive();
  639. }
  640. /////////////////////////////////////////////////////////////////////////////
  641. //
  642. // CScopeWizSetRange property page
  643. //
  644. /////////////////////////////////////////////////////////////////////////////
  645. IMPLEMENT_DYNCREATE(CScopeWizSetRange, CPropertyPageBase)
  646. CScopeWizSetRange::CScopeWizSetRange() : CPropertyPageBase(CScopeWizSetRange::IDD)
  647. {
  648. //{{AFX_DATA_INIT(CScopeWizSetRange)
  649. // NOTE: the ClassWizard will add member initialization here
  650. //}}AFX_DATA_INIT
  651. m_bAutoUpdateMask = FALSE;
  652. InitWiz97(FALSE, IDS_SCOPE_WIZ_SCOPE_TITLE, IDS_SCOPE_WIZ_SCOPE_SUBTITLE);
  653. }
  654. CScopeWizSetRange::~CScopeWizSetRange()
  655. {
  656. }
  657. void CScopeWizSetRange::DoDataExchange(CDataExchange* pDX)
  658. {
  659. CPropertyPageBase::DoDataExchange(pDX);
  660. //{{AFX_DATA_MAP(CScopeWizSetRange)
  661. DDX_Control(pDX, IDC_SPIN_MASK_LENGTH, m_spinMaskLength);
  662. DDX_Control(pDX, IDC_EDIT_MASK_LENGTH, m_editMaskLength);
  663. //}}AFX_DATA_MAP
  664. DDX_Control(pDX, IDC_IPADDR_POOL_START, m_ipaStart);
  665. DDX_Control(pDX, IDC_IPADDR_POOL_STOP, m_ipaEnd);
  666. DDX_Control(pDX, IDC_IPADDR_SUBNET_MASK, m_ipaSubnetMask);
  667. }
  668. BEGIN_MESSAGE_MAP(CScopeWizSetRange, CPropertyPageBase)
  669. //{{AFX_MSG_MAP(CScopeWizSetRange)
  670. ON_EN_KILLFOCUS(IDC_IPADDR_POOL_START, OnKillfocusPoolStart)
  671. ON_EN_KILLFOCUS(IDC_IPADDR_POOL_STOP, OnKillfocusPoolStop)
  672. ON_EN_CHANGE(IDC_EDIT_MASK_LENGTH, OnChangeEditMaskLength)
  673. ON_EN_KILLFOCUS(IDC_IPADDR_SUBNET_MASK, OnKillfocusSubnetMask)
  674. ON_EN_CHANGE(IDC_IPADDR_POOL_START, OnChangePoolStart)
  675. ON_EN_CHANGE(IDC_IPADDR_POOL_STOP, OnChangePoolStop)
  676. //}}AFX_MSG_MAP
  677. END_MESSAGE_MAP()
  678. /////////////////////////////////////////////////////////////////////////////
  679. //
  680. // CScopeWizSetRange message handlers
  681. //
  682. /////////////////////////////////////////////////////////////////////////////
  683. BOOL CScopeWizSetRange::OnInitDialog()
  684. {
  685. CPropertyPageBase::OnInitDialog();
  686. m_spinMaskLength.SetRange(MASK_MIN, MASK_MAX);
  687. return TRUE; // return TRUE unless you set the focus to a control
  688. // EXCEPTION: OCX Property Pages should return FALSE
  689. }
  690. LRESULT CScopeWizSetRange::OnWizardNext()
  691. {
  692. // check to make sure the address range is not in the multicast area
  693. CDhcpIpRange rangeScope, rangeMulticast;
  694. DWORD dwSubnetMask;
  695. GetScopeRange(&rangeScope);
  696. rangeMulticast.SetAddr(MCAST_ADDRESS_MIN, TRUE);
  697. rangeMulticast.SetAddr(MCAST_ADDRESS_MAX, FALSE);
  698. dwSubnetMask = GetSubnetMask();
  699. // make sure the starting < ending
  700. if (rangeScope.QueryAddr(TRUE) > rangeScope.QueryAddr(FALSE))
  701. {
  702. AfxMessageBox(IDS_ERR_IP_RANGE_INV_START);
  703. m_ipaStart.SetFocus();
  704. return -1;
  705. }
  706. if (rangeScope.IsOverlap(rangeMulticast))
  707. {
  708. AfxMessageBox(IDS_SCOPE_CONTAINS_MULTICAST);
  709. m_ipaStart.SetFocus();
  710. return -1;
  711. }
  712. // make sure that the starting address != subnet address
  713. if ((rangeScope.QueryAddr(TRUE) & ~dwSubnetMask) == (DWORD) 0)
  714. {
  715. Trace0("CScopeWizSetRange::OnWizardNext() - starting range is 0 for subnet\n");
  716. AfxMessageBox(IDS_ERR_IP_RANGE_INV_START);
  717. m_ipaStart.SetFocus();
  718. return -1;
  719. }
  720. // make sure that the subnet broadcast address is not the ending address
  721. if ((rangeScope.QueryAddr(FALSE) & ~dwSubnetMask) == ~dwSubnetMask)
  722. {
  723. Trace0("CScopeWizSetRange::OnWizardNext() - ending range is subnet broadcast addr\n");
  724. AfxMessageBox(IDS_ERR_IP_RANGE_INV_END);
  725. m_ipaEnd.SetFocus();
  726. return -1;
  727. }
  728. if (FScopeExists(rangeScope, dwSubnetMask))
  729. {
  730. // tell the user this scope exists
  731. Trace0("CScopeWizSetRange::OnWizardNext() - scope already exists\n");
  732. AfxMessageBox(IDS_ERR_SCOPE_EXISTS);
  733. m_ipaStart.SetFocus();
  734. return -1;
  735. }
  736. // now figure out where to go...
  737. if (DetermineSubnetId(TRUE) != DetermineSubnetId(FALSE))
  738. {
  739. //
  740. // The subnet range that was entered spans more than
  741. // one subnet. Query the user to create a superscope.
  742. //
  743. return IDW_SCOPE_CREATE_SUPERSCOPE;
  744. }
  745. else
  746. {
  747. //
  748. // The range is only one subnet. Proceed as normal.
  749. //
  750. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  751. pScopeWiz->SetCreateSuperscope(FALSE);
  752. return IDW_SCOPE_SET_EXCLUSIONS;
  753. }
  754. }
  755. BOOL CScopeWizSetRange::FScopeExists(CDhcpIpRange & rangeScope, DWORD dwMask)
  756. {
  757. BOOL fFound = FALSE;
  758. DWORD dwScopeId = rangeScope.QueryAddr(TRUE) & dwMask;
  759. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  760. SPITFSNode spServerNode, spSuperscopeNode;
  761. // Get the correct node depending up how the wizard was launched
  762. // ie. either from the Server node or the superscope node.
  763. if (pScopeWiz->m_strSuperscopeName.IsEmpty())
  764. {
  765. spServerNode = pScopeWiz->GetNode();
  766. }
  767. else
  768. {
  769. spSuperscopeNode = pScopeWiz->GetNode();
  770. spSuperscopeNode->GetParent(&spServerNode);
  771. }
  772. CDhcpServer * pServer = GETHANDLER(CDhcpServer, spServerNode);
  773. CSubnetInfo subnetInfo;
  774. if (pServer->m_pSubnetInfoCache->Lookup(dwScopeId, subnetInfo))
  775. {
  776. fFound = TRUE;
  777. }
  778. return fFound;
  779. }
  780. LRESULT CScopeWizSetRange::OnWizardBack()
  781. {
  782. return IDW_SCOPE_NAME;
  783. }
  784. BOOL CScopeWizSetRange::OnSetActive()
  785. {
  786. m_fPageActive = TRUE;
  787. UpdateButtons();
  788. return CPropertyPageBase::OnSetActive();
  789. }
  790. BOOL CScopeWizSetRange::OnKillActive()
  791. {
  792. m_fPageActive = FALSE;
  793. UpdateButtons();
  794. return CPropertyPageBase::OnKillActive();
  795. }
  796. void CScopeWizSetRange::OnKillfocusPoolStart()
  797. {
  798. if (m_fPageActive)
  799. {
  800. SuggestSubnetMask();
  801. }
  802. }
  803. void CScopeWizSetRange::OnKillfocusPoolStop()
  804. {
  805. if (m_fPageActive)
  806. {
  807. SuggestSubnetMask();
  808. }
  809. }
  810. void CScopeWizSetRange::OnChangeEditMaskLength()
  811. {
  812. if (m_bAutoUpdateMask)
  813. {
  814. CString strText;
  815. m_editMaskLength.GetWindowText(strText);
  816. int nLength = _ttoi(strText);
  817. if (nLength < MASK_MIN)
  818. {
  819. LPTSTR pBuf = strText.GetBuffer(5);
  820. _itot(MASK_MIN, pBuf, 10);
  821. strText.ReleaseBuffer();
  822. m_editMaskLength.SetWindowText(strText);
  823. m_spinMaskLength.SetPos(MASK_MIN);
  824. MessageBeep(MB_ICONEXCLAMATION);
  825. }
  826. else
  827. if (nLength > MASK_MAX)
  828. {
  829. LPTSTR pBuf = strText.GetBuffer(5);
  830. _itot(MASK_MAX, pBuf, 10);
  831. strText.ReleaseBuffer();
  832. m_editMaskLength.SetWindowText(strText);
  833. m_spinMaskLength.SetPos(MASK_MAX);
  834. MessageBeep(MB_ICONEXCLAMATION);
  835. }
  836. UpdateMask(TRUE);
  837. UpdateButtons();
  838. }
  839. }
  840. void CScopeWizSetRange::OnKillfocusSubnetMask()
  841. {
  842. if (m_bAutoUpdateMask)
  843. {
  844. UpdateMask(FALSE);
  845. }
  846. }
  847. void CScopeWizSetRange::OnChangePoolStop()
  848. {
  849. UpdateButtons();
  850. }
  851. void CScopeWizSetRange::OnChangePoolStart()
  852. {
  853. UpdateButtons();
  854. }
  855. /////////////////////////////////////////////////////////////////////////////
  856. //
  857. // CScopeWizSetRange implementation specific
  858. //
  859. /////////////////////////////////////////////////////////////////////////////
  860. BOOL
  861. CScopeWizSetRange::GetScopeRange(CDhcpIpRange * pdhcpIpRange)
  862. {
  863. DHCP_IP_RANGE dhcpIpRange;
  864. if ( !m_ipaStart.GetAddress( & dhcpIpRange.StartAddress ) )
  865. {
  866. return FALSE ;
  867. }
  868. if ( !m_ipaEnd.GetAddress( & dhcpIpRange.EndAddress ) )
  869. {
  870. return FALSE;
  871. }
  872. *pdhcpIpRange = dhcpIpRange;
  873. return TRUE;
  874. }
  875. DHCP_IP_ADDRESS
  876. CScopeWizSetRange::GetSubnetMask()
  877. {
  878. DWORD dwAddress;
  879. m_ipaSubnetMask.GetAddress(&dwAddress);
  880. return dwAddress;
  881. }
  882. void
  883. CScopeWizSetRange::UpdateButtons()
  884. {
  885. DWORD lStart, lEnd, lMask;
  886. m_ipaStart.GetAddress(&lStart);
  887. m_ipaEnd.GetAddress(&lEnd);
  888. m_ipaSubnetMask.GetAddress(&lMask);
  889. if (lStart && lEnd)
  890. GetHolder()->SetWizardButtonsMiddle(TRUE);
  891. else
  892. GetHolder()->SetWizardButtonsMiddle(FALSE);
  893. }
  894. //
  895. // Update the subnet mask field using either the length identifier or
  896. // the acutal address as the base
  897. //
  898. void
  899. CScopeWizSetRange::UpdateMask(BOOL bUseLength)
  900. {
  901. if (bUseLength)
  902. {
  903. DWORD dwAddress = 0xFFFFFFFF;
  904. int nLength = m_spinMaskLength.GetPos();
  905. if (nLength)
  906. dwAddress = dwAddress << (32 - (DWORD) nLength);
  907. else
  908. dwAddress = 0;
  909. m_ipaSubnetMask.SetAddress(dwAddress);
  910. }
  911. else
  912. {
  913. DWORD dwAddress, dwTestMask = 0x80000000;
  914. int nLength = 0;
  915. m_ipaSubnetMask.GetAddress(&dwAddress);
  916. while (TRUE)
  917. {
  918. if (dwAddress & dwTestMask)
  919. {
  920. nLength++;
  921. dwTestMask = dwTestMask >> 1;
  922. }
  923. else
  924. {
  925. break;
  926. }
  927. }
  928. m_spinMaskLength.SetPos(nLength);
  929. }
  930. }
  931. //
  932. // Given the start and end IP addresses, suggest a good subnet mask
  933. // (unless the latter has been filled in already, of course)
  934. //
  935. void
  936. CScopeWizSetRange::SuggestSubnetMask()
  937. {
  938. DWORD lStart, lEnd, lMask, lMask2;
  939. m_ipaSubnetMask.GetAddress(&lMask);
  940. if (lMask != 0L)
  941. {
  942. //
  943. // Already has an address, do nothing
  944. //
  945. return;
  946. }
  947. m_ipaStart.GetAddress(&lStart);
  948. m_ipaEnd.GetAddress(&lEnd);
  949. lMask = DefaultNetMaskForIpAddress( lStart );
  950. lMask2 = DefaultNetMaskForIpAddress( lEnd );
  951. /*
  952. if (lMask != lMask2)
  953. {
  954. //
  955. // Forget about suggesting a subnet mask
  956. //
  957. lMask = 0;
  958. }
  959. */
  960. m_bAutoUpdateMask = TRUE;
  961. if (lMask != 0)
  962. {
  963. m_ipaSubnetMask.SetAddress(lMask);
  964. UpdateMask(FALSE);
  965. }
  966. }
  967. DWORD
  968. CScopeWizSetRange::DefaultNetMaskForIpAddress
  969. (
  970. DWORD dwAddress
  971. )
  972. {
  973. DWORD dwMask = 0L;
  974. if (!(dwAddress & 0x80000000))
  975. {
  976. //
  977. // Class A - mask 255.0.0.0
  978. //
  979. dwMask = 0xFF000000;
  980. }
  981. else
  982. if (!(dwAddress & 0x40000000))
  983. {
  984. //
  985. // Class B - mask 255.255.0.0
  986. //
  987. dwMask = 0xFFFF0000;
  988. }
  989. else
  990. if (!(dwAddress & 0x20000000))
  991. {
  992. //
  993. // Class C - mask 255.255.255.0
  994. //
  995. dwMask = 0xFFFFFF00;
  996. }
  997. return dwMask;
  998. }
  999. //
  1000. // Returns the Subnet IP identifier of either the
  1001. // scope's starting or ending IP Address.
  1002. //
  1003. DWORD
  1004. CScopeWizSetRange::DetermineSubnetId
  1005. (
  1006. BOOL bStartIpAddress
  1007. )
  1008. {
  1009. DWORD lAddress, lMask;
  1010. m_ipaSubnetMask.GetAddress(&lMask);
  1011. if (bStartIpAddress)
  1012. m_ipaStart.GetAddress(&lAddress);
  1013. else
  1014. m_ipaEnd.GetAddress(&lAddress);
  1015. return (lAddress & lMask);
  1016. }
  1017. /////////////////////////////////////////////////////////////////////////////
  1018. //
  1019. // CScopeWizSetExclusions property page
  1020. //
  1021. /////////////////////////////////////////////////////////////////////////////
  1022. IMPLEMENT_DYNCREATE(CScopeWizSetExclusions, CPropertyPageBase)
  1023. CScopeWizSetExclusions::CScopeWizSetExclusions() : CPropertyPageBase(CScopeWizSetExclusions::IDD)
  1024. {
  1025. //{{AFX_DATA_INIT(CScopeWizSetExclusions)
  1026. //}}AFX_DATA_INIT
  1027. InitWiz97(FALSE, IDS_SCOPE_WIZ_EXCLUSIONS_TITLE, IDS_SCOPE_WIZ_EXCLUSIONS_SUBTITLE);
  1028. }
  1029. CScopeWizSetExclusions::~CScopeWizSetExclusions()
  1030. {
  1031. while (m_listExclusions.GetCount())
  1032. delete m_listExclusions.RemoveHead();
  1033. }
  1034. void CScopeWizSetExclusions::DoDataExchange(CDataExchange* pDX)
  1035. {
  1036. CPropertyPageBase::DoDataExchange(pDX);
  1037. //{{AFX_DATA_MAP(CScopeWizSetExclusions)
  1038. DDX_Control(pDX, IDC_LIST_EXCLUSION_RANGES, m_listboxExclusions);
  1039. DDX_Control(pDX, IDC_BUTTON_EXCLUSION_DELETE, m_buttonExclusionDelete);
  1040. DDX_Control(pDX, IDC_BUTTON_EXCLUSION_ADD, m_buttonExclusionAdd);
  1041. //}}AFX_DATA_MAP
  1042. //
  1043. // IP Address custom controls
  1044. //
  1045. DDX_Control(pDX, IDC_IPADDR_EXCLUSION_START, m_ipaStart);
  1046. DDX_Control(pDX, IDC_IPADDR_EXCLUSION_END, m_ipaEnd);
  1047. }
  1048. BEGIN_MESSAGE_MAP(CScopeWizSetExclusions, CPropertyPageBase)
  1049. //{{AFX_MSG_MAP(CScopeWizSetExclusions)
  1050. ON_BN_CLICKED(IDC_BUTTON_EXCLUSION_ADD, OnButtonExclusionAdd)
  1051. ON_BN_CLICKED(IDC_BUTTON_EXCLUSION_DELETE, OnButtonExclusionDelete)
  1052. //}}AFX_MSG_MAP
  1053. ON_EN_CHANGE(IDC_IPADDR_EXCLUSION_START, OnChangeExclusionStart)
  1054. ON_EN_CHANGE(IDC_IPADDR_EXCLUSION_END, OnChangeExclusionEnd)
  1055. END_MESSAGE_MAP()
  1056. /////////////////////////////////////////////////////////////////////////////
  1057. //
  1058. // CScopeWizSetExclusions message handlers
  1059. //
  1060. /////////////////////////////////////////////////////////////////////////////
  1061. BOOL CScopeWizSetExclusions::OnInitDialog()
  1062. {
  1063. CPropertyPageBase::OnInitDialog();
  1064. return TRUE; // return TRUE unless you set the focus to a control
  1065. // EXCEPTION: OCX Property Pages should return FALSE
  1066. }
  1067. LRESULT CScopeWizSetExclusions::OnWizardNext()
  1068. {
  1069. return IDW_SCOPE_LEASE_TIME;
  1070. }
  1071. LRESULT CScopeWizSetExclusions::OnWizardBack()
  1072. {
  1073. return IDW_SCOPE_SET_SCOPE;
  1074. }
  1075. BOOL CScopeWizSetExclusions::OnSetActive()
  1076. {
  1077. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1078. UpdateButtons();
  1079. return CPropertyPageBase::OnSetActive();
  1080. }
  1081. void CScopeWizSetExclusions::OnChangeExclusionStart()
  1082. {
  1083. UpdateButtons();
  1084. }
  1085. void CScopeWizSetExclusions::OnChangeExclusionEnd()
  1086. {
  1087. UpdateButtons();
  1088. }
  1089. void CScopeWizSetExclusions::OnButtonExclusionAdd()
  1090. {
  1091. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1092. DWORD err = 0;
  1093. CDhcpIpRange dhcpExclusionRange;
  1094. CDhcpIpRange dhcpScopeRange;
  1095. ((CScopeWiz *)GetHolder())->GetScopeRange(&dhcpScopeRange);
  1096. //
  1097. // Get the data into a range object.
  1098. //
  1099. if ( !GetExclusionRange(dhcpExclusionRange) )
  1100. {
  1101. err = IDS_ERR_IP_RANGE_INVALID ;
  1102. }
  1103. else if ( IsOverlappingRange( dhcpExclusionRange ) )
  1104. {
  1105. //
  1106. // Walk the current list, determining if the new range is valid.
  1107. // Then, if OK, verify that it's really a sub-range of the current range.
  1108. //
  1109. err = IDS_ERR_IP_RANGE_OVERLAP ;
  1110. m_ipaStart.SetFocus();
  1111. }
  1112. else if ( ! dhcpExclusionRange.IsSubset( dhcpScopeRange ) )
  1113. {
  1114. //
  1115. // Guarantee that the new range is an (improper) subset of the scope's range
  1116. //
  1117. err = IDS_ERR_IP_RANGE_NOT_SUBSET ;
  1118. m_ipaStart.SetFocus();
  1119. }
  1120. if ( err == 0 )
  1121. {
  1122. //TRY
  1123. {
  1124. //
  1125. // Create a new IP range object and add it to the current list
  1126. //
  1127. CDhcpIpRange * pIpRange = new CDhcpIpRange( dhcpExclusionRange ) ;
  1128. m_listExclusions.AddTail(pIpRange);
  1129. //
  1130. // Refill the exclusions listbox including the new item.
  1131. //
  1132. Fill( (int) (m_listExclusions.GetCount() - 1) ) ;
  1133. }
  1134. //CATCH_ALL(e)
  1135. //{
  1136. // err = ERROR_NOT_ENOUGH_MEMORY ;
  1137. //}
  1138. //END_CATCH_ALL
  1139. }
  1140. if ( err )
  1141. {
  1142. ::DhcpMessageBox( err ) ;
  1143. }
  1144. else
  1145. {
  1146. //
  1147. // Succesfully added the exlusion range, now blank out the
  1148. // ip controls
  1149. //
  1150. m_ipaStart.ClearAddress();
  1151. m_ipaEnd.ClearAddress();
  1152. m_ipaStart.SetFocus();
  1153. }
  1154. }
  1155. void CScopeWizSetExclusions::OnButtonExclusionDelete()
  1156. {
  1157. //
  1158. // Index into the listbox, delete the item from the active list
  1159. // and move its data into the edit controls
  1160. //
  1161. int index = m_listboxExclusions.GetCurSel() ;
  1162. ASSERT( index >= 0 ) ; // Button should not be enabled if no selection.
  1163. if ( index < 0 )
  1164. {
  1165. return ;
  1166. }
  1167. POSITION pos = m_listExclusions.FindIndex(index);
  1168. CDhcpIpRange * pdhcRange = (CDhcpIpRange *) m_listExclusions.GetAt(pos);
  1169. m_listExclusions.RemoveAt(pos);
  1170. ASSERT( pdhcRange != NULL ) ;
  1171. //
  1172. // Put the deleted range into the exclusions controls
  1173. //
  1174. FillExcl( pdhcRange ) ;
  1175. //
  1176. // Refill the list box and call HandleActivation()
  1177. //
  1178. if ( index >= m_listboxExclusions.GetCount() )
  1179. {
  1180. index-- ;
  1181. }
  1182. Fill( index ) ;
  1183. m_ipaStart.SetFocus();
  1184. UpdateButtons();
  1185. }
  1186. //
  1187. // Format the IP range pair into the exclusion edit controls
  1188. //
  1189. void
  1190. CScopeWizSetExclusions::FillExcl
  1191. (
  1192. CDhcpIpRange * pdhcIpRange
  1193. )
  1194. {
  1195. LONG lStart = pdhcIpRange->QueryAddr( TRUE );
  1196. LONG lEnd = pdhcIpRange->QueryAddr( FALSE );
  1197. m_ipaStart.SetAddress( lStart ) ;
  1198. m_ipaStart.SetModify( TRUE ) ;
  1199. m_ipaStart.Invalidate() ;
  1200. //
  1201. // If the ending address is the same as the starting address,
  1202. // do not fill in the ending address.
  1203. //
  1204. if (lStart != lEnd)
  1205. {
  1206. m_ipaEnd.SetAddress( lEnd ) ;
  1207. }
  1208. else
  1209. {
  1210. m_ipaEnd.ClearAddress();
  1211. }
  1212. m_ipaEnd.SetModify( TRUE ) ;
  1213. m_ipaEnd.Invalidate() ;
  1214. }
  1215. //
  1216. // Convert the IP address range controls to a range.
  1217. //
  1218. BOOL
  1219. CScopeWizSetExclusions::GetExclusionRange
  1220. (
  1221. CDhcpIpRange & dhcIpRange
  1222. )
  1223. {
  1224. DHCP_IP_RANGE dhipr ;
  1225. if ( !m_ipaStart.GetAddress( & dhipr.StartAddress ) )
  1226. {
  1227. m_ipaStart.SetFocus();
  1228. return FALSE ;
  1229. }
  1230. if ( !m_ipaEnd.GetAddress( & dhipr.EndAddress ) )
  1231. {
  1232. //
  1233. // If no ending range was specified, assume a singular exlusion
  1234. // (the starting address) was requested.
  1235. //
  1236. m_ipaEnd.SetFocus();
  1237. dhipr.EndAddress = dhipr.StartAddress;
  1238. }
  1239. dhcIpRange = dhipr ;
  1240. return (BOOL) dhcIpRange ;
  1241. }
  1242. BOOL
  1243. CScopeWizSetExclusions::IsOverlappingRange
  1244. (
  1245. CDhcpIpRange & dhcpIpRange
  1246. )
  1247. {
  1248. POSITION pos;
  1249. CDhcpIpRange * pdhcpRange ;
  1250. BOOL bOverlap = FALSE ;
  1251. pos = m_listExclusions.GetHeadPosition();
  1252. while ( pos )
  1253. {
  1254. pdhcpRange = m_listExclusions.GetNext(pos);
  1255. if ( bOverlap = pdhcpRange->IsOverlap( dhcpIpRange ) )
  1256. {
  1257. break ;
  1258. }
  1259. }
  1260. return bOverlap ;
  1261. }
  1262. //
  1263. // Fill the exclusions listbox from the current list
  1264. //
  1265. void
  1266. CScopeWizSetExclusions::Fill
  1267. (
  1268. int nCurSel,
  1269. BOOL bToggleRedraw
  1270. )
  1271. {
  1272. POSITION pos;
  1273. CDhcpIpRange * pIpRange ;
  1274. CString strIp1 ;
  1275. CString strIp2 ;
  1276. CString strFormatPair ;
  1277. CString strFormatSingleton ;
  1278. TCHAR chBuff [STRING_LENGTH_MAX] ;
  1279. if ( ! strFormatPair.LoadString( IDS_INFO_FORMAT_IP_RANGE ) )
  1280. {
  1281. return ;
  1282. }
  1283. if ( ! strFormatSingleton.LoadString( IDS_INFO_FORMAT_IP_UNITARY ) )
  1284. {
  1285. return ;
  1286. }
  1287. if ( bToggleRedraw )
  1288. {
  1289. m_listboxExclusions.SetRedraw( FALSE ) ;
  1290. }
  1291. m_listboxExclusions.ResetContent() ;
  1292. pos = m_listExclusions.GetHeadPosition();
  1293. while ( pos )
  1294. {
  1295. pIpRange = m_listExclusions.GetNext(pos);
  1296. DHCP_IP_RANGE dhipr = *pIpRange ;
  1297. CString & strFmt = dhipr.StartAddress == dhipr.EndAddress
  1298. ? strFormatSingleton
  1299. : strFormatPair ;
  1300. //
  1301. // Format the IP addresses
  1302. //
  1303. UtilCvtIpAddrToWstr( dhipr.StartAddress, &strIp1 ) ;
  1304. UtilCvtIpAddrToWstr( dhipr.EndAddress, &strIp2 ) ;
  1305. //
  1306. // Construct the display line
  1307. //
  1308. ::wsprintf( chBuff,
  1309. (LPCTSTR) strFmt,
  1310. (LPCTSTR) strIp1,
  1311. (LPCTSTR) strIp2 ) ;
  1312. //
  1313. // Add it to the list box.
  1314. //
  1315. if ( m_listboxExclusions.AddString( chBuff ) < 0 )
  1316. {
  1317. break ;
  1318. }
  1319. }
  1320. //
  1321. // Check that we loaded the list box successfully.
  1322. //
  1323. if ( pos != NULL )
  1324. {
  1325. AfxMessageBox( IDS_ERR_DLG_UPDATE ) ;
  1326. }
  1327. if ( bToggleRedraw )
  1328. {
  1329. m_listboxExclusions.SetRedraw( TRUE ) ;
  1330. m_listboxExclusions.Invalidate() ;
  1331. }
  1332. if ( nCurSel >= 0 )
  1333. {
  1334. m_listboxExclusions.SetCurSel( nCurSel ) ;
  1335. }
  1336. }
  1337. void CScopeWizSetExclusions::UpdateButtons()
  1338. {
  1339. DWORD dwAddress;
  1340. BOOL bEnable;
  1341. m_ipaStart.GetAddress(&dwAddress);
  1342. if (dwAddress)
  1343. {
  1344. bEnable = TRUE;
  1345. }
  1346. else
  1347. {
  1348. bEnable = FALSE;
  1349. if (m_buttonExclusionAdd.GetButtonStyle() & BS_DEFPUSHBUTTON)
  1350. {
  1351. m_buttonExclusionAdd.SetButtonStyle(BS_PUSHBUTTON);
  1352. }
  1353. }
  1354. m_buttonExclusionAdd.EnableWindow(bEnable);
  1355. if (m_listboxExclusions.GetCurSel() != LB_ERR)
  1356. {
  1357. bEnable = TRUE;
  1358. }
  1359. else
  1360. {
  1361. bEnable = FALSE;
  1362. if (m_buttonExclusionDelete.GetButtonStyle() & BS_DEFPUSHBUTTON)
  1363. {
  1364. m_buttonExclusionDelete.SetButtonStyle(BS_PUSHBUTTON);
  1365. }
  1366. }
  1367. m_buttonExclusionDelete.EnableWindow(bEnable);
  1368. }
  1369. /////////////////////////////////////////////////////////////////////////////
  1370. //
  1371. // CScopeWizLeaseTime property page
  1372. //
  1373. /////////////////////////////////////////////////////////////////////////////
  1374. IMPLEMENT_DYNCREATE(CScopeWizLeaseTime, CPropertyPageBase)
  1375. CScopeWizLeaseTime::CScopeWizLeaseTime() : CPropertyPageBase(CScopeWizLeaseTime::IDD)
  1376. {
  1377. //{{AFX_DATA_INIT(CScopeWizLeaseTime)
  1378. //}}AFX_DATA_INIT
  1379. InitWiz97(FALSE, IDS_SCOPE_WIZ_LEASE_TITLE, IDS_SCOPE_WIZ_LEASE_SUBTITLE);
  1380. }
  1381. CScopeWizLeaseTime::~CScopeWizLeaseTime()
  1382. {
  1383. }
  1384. void CScopeWizLeaseTime::DoDataExchange(CDataExchange* pDX)
  1385. {
  1386. CPropertyPageBase::DoDataExchange(pDX);
  1387. //{{AFX_DATA_MAP(CScopeWizLeaseTime)
  1388. DDX_Control(pDX, IDC_SPIN_LEASE_MINUTES, m_spinMinutes);
  1389. DDX_Control(pDX, IDC_SPIN_LEASE_HOURS, m_spinHours);
  1390. DDX_Control(pDX, IDC_SPIN_LEASE_DAYS, m_spinDays);
  1391. DDX_Control(pDX, IDC_EDIT_LEASE_MINUTES, m_editMinutes);
  1392. DDX_Control(pDX, IDC_EDIT_LEASE_HOURS, m_editHours);
  1393. DDX_Control(pDX, IDC_EDIT_LEASE_DAYS, m_editDays);
  1394. //}}AFX_DATA_MAP
  1395. }
  1396. BEGIN_MESSAGE_MAP(CScopeWizLeaseTime, CPropertyPageBase)
  1397. //{{AFX_MSG_MAP(CScopeWizLeaseTime)
  1398. ON_EN_CHANGE(IDC_EDIT_LEASE_HOURS, OnChangeEditLeaseHours)
  1399. ON_EN_CHANGE(IDC_EDIT_LEASE_MINUTES, OnChangeEditLeaseMinutes)
  1400. //}}AFX_MSG_MAP
  1401. END_MESSAGE_MAP()
  1402. /////////////////////////////////////////////////////////////////////////////
  1403. //
  1404. // CScopeWizLeaseTime message handlers
  1405. //
  1406. /////////////////////////////////////////////////////////////////////////////
  1407. BOOL CScopeWizLeaseTime::OnInitDialog()
  1408. {
  1409. CPropertyPageBase::OnInitDialog();
  1410. m_spinMinutes.SetRange(0, MINUTES_MAX);
  1411. m_spinHours.SetRange(0, HOURS_MAX);
  1412. m_spinDays.SetRange(0, 999);
  1413. m_editMinutes.LimitText(2);
  1414. m_editHours.LimitText(2);
  1415. m_editDays.LimitText(3);
  1416. m_spinMinutes.SetPos(CScopeWizLeaseTime::m_nMinutesDefault);
  1417. m_spinHours.SetPos(CScopeWizLeaseTime::m_nHoursDefault);
  1418. m_spinDays.SetPos(CScopeWizLeaseTime::m_nDaysDefault);
  1419. ActivateDuration(TRUE);
  1420. return TRUE; // return TRUE unless you set the focus to a control
  1421. // EXCEPTION: OCX Property Pages should return FALSE
  1422. }
  1423. LRESULT CScopeWizLeaseTime::OnWizardNext()
  1424. {
  1425. DWORD dwLeaseTime = GetLeaseTime();
  1426. if (dwLeaseTime == 0)
  1427. {
  1428. AfxMessageBox(IDS_ERR_NO_DURATION_SPECIFIED);
  1429. return -1;
  1430. }
  1431. else
  1432. {
  1433. return IDW_SCOPE_CONFIGURE_OPTIONS;
  1434. }
  1435. }
  1436. LRESULT CScopeWizLeaseTime::OnWizardBack()
  1437. {
  1438. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1439. if (pScopeWiz->GetCreateSuperscope())
  1440. {
  1441. return IDW_SCOPE_CREATE_SUPERSCOPE;
  1442. }
  1443. else
  1444. {
  1445. return IDW_SCOPE_SET_EXCLUSIONS;
  1446. }
  1447. }
  1448. BOOL CScopeWizLeaseTime::OnSetActive()
  1449. {
  1450. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1451. return CPropertyPageBase::OnSetActive();
  1452. }
  1453. void CScopeWizLeaseTime::OnChangeEditLeaseHours()
  1454. {
  1455. if (IsWindow(m_editHours.GetSafeHwnd()))
  1456. {
  1457. CString strText;
  1458. m_editHours.GetWindowText(strText);
  1459. // check to see if the value is greater than the max
  1460. if (_ttoi(strText) > HOURS_MAX)
  1461. {
  1462. LPTSTR pBuf = strText.GetBuffer(5);
  1463. _itot(HOURS_MAX, pBuf, 10);
  1464. strText.ReleaseBuffer();
  1465. m_editHours.SetWindowText(strText);
  1466. m_spinHours.SetPos(HOURS_MAX);
  1467. MessageBeep(MB_ICONEXCLAMATION);
  1468. }
  1469. }
  1470. }
  1471. void CScopeWizLeaseTime::OnChangeEditLeaseMinutes()
  1472. {
  1473. if (IsWindow(m_editMinutes.GetSafeHwnd()))
  1474. {
  1475. CString strText;
  1476. m_editMinutes.GetWindowText(strText);
  1477. // check to see if the value is greater than the max
  1478. if (_ttoi(strText) > MINUTES_MAX)
  1479. {
  1480. LPTSTR pBuf = strText.GetBuffer(5);
  1481. _itot(MINUTES_MAX, pBuf, 10);
  1482. strText.ReleaseBuffer();
  1483. m_editMinutes.SetWindowText(strText);
  1484. m_spinMinutes.SetPos(MINUTES_MAX);
  1485. MessageBeep(MB_ICONEXCLAMATION);
  1486. }
  1487. }
  1488. }
  1489. DWORD
  1490. CScopeWizLeaseTime::GetLeaseTime()
  1491. {
  1492. DWORD dwLeaseTime = 0;
  1493. int nDays, nHours, nMinutes;
  1494. nDays = m_spinDays.GetPos();
  1495. nHours = m_spinHours.GetPos();
  1496. nMinutes = m_spinMinutes.GetPos();
  1497. //
  1498. // Lease time is in minutes so convert
  1499. //
  1500. dwLeaseTime = UtilConvertLeaseTime(nDays, nHours, nMinutes);
  1501. return dwLeaseTime;
  1502. }
  1503. void
  1504. CScopeWizLeaseTime::ActivateDuration
  1505. (
  1506. BOOL fActive
  1507. )
  1508. {
  1509. m_spinMinutes.EnableWindow(fActive);
  1510. m_spinHours.EnableWindow(fActive);
  1511. m_spinDays.EnableWindow(fActive);
  1512. m_editMinutes.EnableWindow(fActive);
  1513. m_editHours.EnableWindow(fActive);
  1514. m_editDays.EnableWindow(fActive);
  1515. GetDlgItem(IDC_STATIC_DAYS)->EnableWindow(fActive);
  1516. GetDlgItem(IDC_STATIC_HOURS)->EnableWindow(fActive);
  1517. GetDlgItem(IDC_STATIC_MINUTES)->EnableWindow(fActive);
  1518. }
  1519. /////////////////////////////////////////////////////////////////////////////
  1520. //
  1521. // CScopeWizCreateSuperscope property page
  1522. //
  1523. /////////////////////////////////////////////////////////////////////////////
  1524. IMPLEMENT_DYNCREATE(CScopeWizCreateSuperscope, CPropertyPageBase)
  1525. CScopeWizCreateSuperscope::CScopeWizCreateSuperscope() : CPropertyPageBase(CScopeWizCreateSuperscope::IDD)
  1526. {
  1527. //{{AFX_DATA_INIT(CScopeWizCreateSuperscope)
  1528. // NOTE: the ClassWizard will add member initialization here
  1529. //}}AFX_DATA_INIT
  1530. InitWiz97(FALSE, IDS_SCOPE_WIZ_SUPERSCOPE_TITLE, IDS_SCOPE_WIZ_SUPERSCOPE_SUBTITLE);
  1531. }
  1532. CScopeWizCreateSuperscope::~CScopeWizCreateSuperscope()
  1533. {
  1534. }
  1535. void CScopeWizCreateSuperscope::DoDataExchange(CDataExchange* pDX)
  1536. {
  1537. CPropertyPageBase::DoDataExchange(pDX);
  1538. //{{AFX_DATA_MAP(CScopeWizCreateSuperscope)
  1539. DDX_Control(pDX, IDC_STATIC_SUPERSCOPE_INFO, m_staticInfo);
  1540. DDX_Control(pDX, IDC_STATIC_WARNING_TEXT, m_staticWarning);
  1541. DDX_Control(pDX, IDC_STATIC_ICON_WARNING, m_staticIcon);
  1542. DDX_Control(pDX, IDC_RADIO_SUPERSCOPE_NO, m_radioNo);
  1543. DDX_Control(pDX, IDC_RADIO_SUPERSCOPE_YES, m_radioYes);
  1544. //}}AFX_DATA_MAP
  1545. }
  1546. BEGIN_MESSAGE_MAP(CScopeWizCreateSuperscope, CPropertyPageBase)
  1547. //{{AFX_MSG_MAP(CScopeWizCreateSuperscope)
  1548. ON_BN_CLICKED(IDC_RADIO_SUPERSCOPE_NO, OnRadioSuperscopeNo)
  1549. ON_BN_CLICKED(IDC_RADIO_SUPERSCOPE_YES, OnRadioSuperscopeYes)
  1550. //}}AFX_MSG_MAP
  1551. END_MESSAGE_MAP()
  1552. /////////////////////////////////////////////////////////////////////////////
  1553. //
  1554. // CScopeWizCreateSuperscope message handlers
  1555. //
  1556. /////////////////////////////////////////////////////////////////////////////
  1557. BOOL CScopeWizCreateSuperscope::OnInitDialog()
  1558. {
  1559. CPropertyPageBase::OnInitDialog();
  1560. m_radioNo.SetCheck(1);
  1561. m_radioYes.SetCheck(0);
  1562. return TRUE; // return TRUE unless you set the focus to a control
  1563. // EXCEPTION: OCX Property Pages should return FALSE
  1564. }
  1565. LRESULT CScopeWizCreateSuperscope::OnWizardNext()
  1566. {
  1567. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1568. pScopeWiz->SetCreateSuperscope(TRUE);
  1569. return IDW_SCOPE_LEASE_TIME;
  1570. }
  1571. LRESULT CScopeWizCreateSuperscope::OnWizardBack()
  1572. {
  1573. return IDW_SCOPE_SET_SCOPE;
  1574. }
  1575. BOOL CScopeWizCreateSuperscope::OnSetActive()
  1576. {
  1577. UpdateButtons();
  1578. UpdateWarning();
  1579. return CPropertyPageBase::OnSetActive();
  1580. }
  1581. void CScopeWizCreateSuperscope::OnRadioSuperscopeNo()
  1582. {
  1583. m_radioNo.SetCheck(1);
  1584. m_radioYes.SetCheck(0);
  1585. UpdateButtons();
  1586. }
  1587. void CScopeWizCreateSuperscope::OnRadioSuperscopeYes()
  1588. {
  1589. m_radioNo.SetCheck(0);
  1590. m_radioYes.SetCheck(1);
  1591. UpdateButtons();
  1592. }
  1593. void
  1594. CScopeWizCreateSuperscope::UpdateButtons()
  1595. {
  1596. if (m_radioYes.GetCheck())
  1597. {
  1598. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1599. }
  1600. else
  1601. {
  1602. GetHolder()->SetWizardButtonsMiddle(FALSE);
  1603. }
  1604. }
  1605. void
  1606. CScopeWizCreateSuperscope::UpdateWarning()
  1607. {
  1608. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1609. CString strText;
  1610. CDhcpIpRange ipRange;
  1611. DHCP_IP_ADDRESS dhcpSubnetMask;
  1612. DHCP_IP_ADDRESS startAddr, endAddr;
  1613. // get the range and mask the user entered
  1614. pScopeWiz->m_pageSetRange.GetScopeRange(&ipRange);
  1615. dhcpSubnetMask = pScopeWiz->m_pageSetRange.GetSubnetMask();
  1616. startAddr = ipRange.QueryAddr(TRUE);
  1617. endAddr = ipRange.QueryAddr(FALSE);
  1618. // now calculate how many addresses per scope
  1619. int nLength = pScopeWiz->m_pageSetRange.m_spinMaskLength.GetPos();
  1620. int nCount = 32 - nLength;
  1621. DWORD dwAddrCount = 1;
  1622. int nAddrCount = (int) (dwAddrCount << (nCount));
  1623. // calculate how many scopes are there
  1624. int nScopeCount = ((endAddr & dhcpSubnetMask) - (startAddr & dhcpSubnetMask)) >> nCount;
  1625. nScopeCount ++;
  1626. // put up the informative text
  1627. strText.Format(IDS_CREATE_SUPERSCOPE_INFO, nScopeCount, nAddrCount);
  1628. m_staticInfo.SetWindowText(strText);
  1629. // check to seee if we need to warn the user
  1630. BOOL fShowWarning = FALSE;
  1631. if (nScopeCount > SCOPE_WARNING_COUNT)
  1632. {
  1633. fShowWarning = TRUE;
  1634. HICON hIcon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION);
  1635. if (hIcon)
  1636. {
  1637. m_staticIcon.ShowWindow(TRUE);
  1638. m_staticIcon.SetIcon(hIcon);
  1639. }
  1640. strText.Format(IDS_CREATE_SUPERSCOPE_WARNING, SCOPE_WARNING_COUNT);
  1641. m_staticWarning.SetWindowText(strText);
  1642. }
  1643. m_staticIcon.ShowWindow(fShowWarning);
  1644. m_staticWarning.ShowWindow(fShowWarning);
  1645. }
  1646. /////////////////////////////////////////////////////////////////////////////
  1647. //
  1648. // CScopeWizFinished property page
  1649. //
  1650. /////////////////////////////////////////////////////////////////////////////
  1651. IMPLEMENT_DYNCREATE(CScopeWizFinished, CPropertyPageBase)
  1652. CScopeWizFinished::CScopeWizFinished() : CPropertyPageBase(CScopeWizFinished::IDD)
  1653. {
  1654. //{{AFX_DATA_INIT(CScopeWizFinished)
  1655. // NOTE: the ClassWizard will add member initialization here
  1656. //}}AFX_DATA_INIT
  1657. InitWiz97(TRUE, 0, 0);
  1658. }
  1659. CScopeWizFinished::~CScopeWizFinished()
  1660. {
  1661. }
  1662. void CScopeWizFinished::DoDataExchange(CDataExchange* pDX)
  1663. {
  1664. CPropertyPageBase::DoDataExchange(pDX);
  1665. //{{AFX_DATA_MAP(CScopeWizFinished)
  1666. DDX_Control(pDX, IDC_STATIC_FINISHED_TITLE, m_staticTitle);
  1667. //}}AFX_DATA_MAP
  1668. }
  1669. BEGIN_MESSAGE_MAP(CScopeWizFinished, CPropertyPageBase)
  1670. //{{AFX_MSG_MAP(CScopeWizFinished)
  1671. // NOTE: the ClassWizard will add message map macros here
  1672. //}}AFX_MSG_MAP
  1673. END_MESSAGE_MAP()
  1674. /////////////////////////////////////////////////////////////////////////////
  1675. //
  1676. // CScopeWizFinished message handlers
  1677. //
  1678. /////////////////////////////////////////////////////////////////////////////
  1679. BOOL CScopeWizFinished::OnInitDialog()
  1680. {
  1681. CPropertyPageBase::OnInitDialog();
  1682. CString strFontName;
  1683. CString strFontSize;
  1684. strFontName.LoadString(IDS_BIG_BOLD_FONT_NAME);
  1685. strFontSize.LoadString(IDS_BIG_BOLD_FONT_SIZE);
  1686. CClientDC dc(this);
  1687. int nFontSize = _ttoi(strFontSize) * 10;
  1688. if (m_fontBig.CreatePointFont(nFontSize, strFontName, &dc))
  1689. m_staticTitle.SetFont(&m_fontBig);
  1690. return TRUE; // return TRUE unless you set the focus to a control
  1691. // EXCEPTION: OCX Property Pages should return FALSE
  1692. }
  1693. LRESULT CScopeWizFinished::OnWizardBack()
  1694. {
  1695. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1696. if (pScopeWiz->m_fOptionsConfigured)
  1697. {
  1698. return IDW_SCOPE_CONFIGURE_ACTIVATE;
  1699. }
  1700. else
  1701. {
  1702. return IDW_SCOPE_CONFIGURE_OPTIONS;
  1703. }
  1704. }
  1705. BOOL CScopeWizFinished::OnWizardFinish()
  1706. {
  1707. DWORD err;
  1708. BEGIN_WAIT_CURSOR;
  1709. err = GetHolder()->OnFinish();
  1710. END_WAIT_CURSOR;
  1711. if (err)
  1712. {
  1713. ::DhcpMessageBox(err);
  1714. return FALSE;
  1715. }
  1716. else
  1717. {
  1718. return TRUE;
  1719. }
  1720. }
  1721. BOOL CScopeWizFinished::OnSetActive()
  1722. {
  1723. GetHolder()->SetWizardButtonsLast(TRUE);
  1724. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1725. GetDlgItem(IDC_STATIC_FINISHED_MORE)->ShowWindow(!pScopeWiz->m_fOptionsConfigured);
  1726. GetDlgItem(IDC_STATIC_FINISHED_MORE2)->ShowWindow(!pScopeWiz->m_fOptionsConfigured);
  1727. GetDlgItem(IDC_STATIC_FINISHED_MORE3)->ShowWindow(!pScopeWiz->m_fOptionsConfigured);
  1728. return CPropertyPageBase::OnSetActive();
  1729. }
  1730. /////////////////////////////////////////////////////////////////////////////
  1731. // CScopeWizWelcome property page
  1732. IMPLEMENT_DYNCREATE(CScopeWizWelcome, CPropertyPageBase)
  1733. CScopeWizWelcome::CScopeWizWelcome() : CPropertyPageBase(CScopeWizWelcome::IDD)
  1734. {
  1735. //{{AFX_DATA_INIT(CScopeWizWelcome)
  1736. // NOTE: the ClassWizard will add member initialization here
  1737. //}}AFX_DATA_INIT
  1738. InitWiz97(TRUE, 0, 0);
  1739. }
  1740. CScopeWizWelcome::~CScopeWizWelcome()
  1741. {
  1742. }
  1743. void CScopeWizWelcome::DoDataExchange(CDataExchange* pDX)
  1744. {
  1745. CPropertyPageBase::DoDataExchange(pDX);
  1746. //{{AFX_DATA_MAP(CScopeWizWelcome)
  1747. DDX_Control(pDX, IDC_STATIC_WELCOME_TITLE, m_staticTitle);
  1748. //}}AFX_DATA_MAP
  1749. }
  1750. BEGIN_MESSAGE_MAP(CScopeWizWelcome, CPropertyPageBase)
  1751. //{{AFX_MSG_MAP(CScopeWizWelcome)
  1752. //}}AFX_MSG_MAP
  1753. END_MESSAGE_MAP()
  1754. /////////////////////////////////////////////////////////////////////////////
  1755. // CScopeWizWelcome message handlers
  1756. BOOL CScopeWizWelcome::OnInitDialog()
  1757. {
  1758. CPropertyPageBase::OnInitDialog();
  1759. CString strFontName;
  1760. CString strFontSize;
  1761. strFontName.LoadString(IDS_BIG_BOLD_FONT_NAME);
  1762. strFontSize.LoadString(IDS_BIG_BOLD_FONT_SIZE);
  1763. CClientDC dc(this);
  1764. int nFontSize = _ttoi(strFontSize) * 10;
  1765. if (m_fontBig.CreatePointFont(nFontSize, strFontName, &dc))
  1766. m_staticTitle.SetFont(&m_fontBig);
  1767. return TRUE; // return TRUE unless you set the focus to a control
  1768. // EXCEPTION: OCX Property Pages should return FALSE
  1769. }
  1770. BOOL CScopeWizWelcome::OnSetActive()
  1771. {
  1772. GetHolder()->SetWizardButtonsFirst(TRUE);
  1773. return CPropertyPageBase::OnSetActive();
  1774. }
  1775. /////////////////////////////////////////////////////////////////////////////
  1776. // CScopeWizConfigOptions property page
  1777. IMPLEMENT_DYNCREATE(CScopeWizConfigOptions, CPropertyPageBase)
  1778. CScopeWizConfigOptions::CScopeWizConfigOptions() : CPropertyPageBase(CScopeWizConfigOptions::IDD)
  1779. {
  1780. //{{AFX_DATA_INIT(CScopeWizConfigOptions)
  1781. // NOTE: the ClassWizard will add member initialization here
  1782. //}}AFX_DATA_INIT
  1783. InitWiz97(FALSE, IDS_SCOPE_WIZ_CONFIG_TITLE, IDS_SCOPE_WIZ_CONFIG_SUBTITLE);
  1784. }
  1785. CScopeWizConfigOptions::~CScopeWizConfigOptions()
  1786. {
  1787. }
  1788. void CScopeWizConfigOptions::DoDataExchange(CDataExchange* pDX)
  1789. {
  1790. CPropertyPageBase::DoDataExchange(pDX);
  1791. //{{AFX_DATA_MAP(CScopeWizConfigOptions)
  1792. // NOTE: the ClassWizard will add DDX and DDV calls here
  1793. //}}AFX_DATA_MAP
  1794. }
  1795. BEGIN_MESSAGE_MAP(CScopeWizConfigOptions, CPropertyPageBase)
  1796. //{{AFX_MSG_MAP(CScopeWizConfigOptions)
  1797. //}}AFX_MSG_MAP
  1798. END_MESSAGE_MAP()
  1799. /////////////////////////////////////////////////////////////////////////////
  1800. // CScopeWizConfigOptions message handlers
  1801. BOOL CScopeWizConfigOptions::OnInitDialog()
  1802. {
  1803. CPropertyPageBase::OnInitDialog();
  1804. ((CButton *) GetDlgItem(IDC_RADIO_YES))->SetCheck(TRUE);
  1805. return TRUE; // return TRUE unless you set the focus to a control
  1806. // EXCEPTION: OCX Property Pages should return FALSE
  1807. }
  1808. LRESULT CScopeWizConfigOptions::OnWizardNext()
  1809. {
  1810. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1811. LRESULT lNextPage = IDW_SCOPE_FINISHED;
  1812. BOOL fConfigureOptionsNow = FALSE;
  1813. if (((CButton *) GetDlgItem(IDC_RADIO_YES))->GetCheck())
  1814. {
  1815. fConfigureOptionsNow = TRUE;
  1816. lNextPage = IDW_SCOPE_CONFIGURE_ROUTER;
  1817. }
  1818. pScopeWiz->m_fOptionsConfigured = fConfigureOptionsNow;
  1819. return lNextPage;
  1820. }
  1821. LRESULT CScopeWizConfigOptions::OnWizardBack()
  1822. {
  1823. return IDW_SCOPE_LEASE_TIME;
  1824. }
  1825. BOOL CScopeWizConfigOptions::OnSetActive()
  1826. {
  1827. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1828. return CPropertyPageBase::OnSetActive();
  1829. }
  1830. /////////////////////////////////////////////////////////////////////////////
  1831. // CScopeWizRouter property page
  1832. IMPLEMENT_DYNCREATE(CScopeWizRouter, CPropertyPageBase)
  1833. CScopeWizRouter::CScopeWizRouter() : CPropertyPageBase(CScopeWizRouter::IDD)
  1834. {
  1835. //{{AFX_DATA_INIT(CScopeWizRouter)
  1836. // NOTE: the ClassWizard will add member initialization here
  1837. //}}AFX_DATA_INIT
  1838. InitWiz97(FALSE, IDS_SCOPE_WIZ_ROUTER_TITLE, IDS_SCOPE_WIZ_ROUTER_SUBTITLE);
  1839. }
  1840. CScopeWizRouter::~CScopeWizRouter()
  1841. {
  1842. }
  1843. void CScopeWizRouter::DoDataExchange(CDataExchange* pDX)
  1844. {
  1845. CPropertyPageBase::DoDataExchange(pDX);
  1846. //{{AFX_DATA_MAP(CScopeWizRouter)
  1847. DDX_Control(pDX, IDC_LIST_DEFAULT_GW_LIST, m_listboxRouters);
  1848. DDX_Control(pDX, IDC_BUTTON_DEFAULT_GW_DELETE, m_buttonDelete);
  1849. DDX_Control(pDX, IDC_BUTTON_DEFAULT_GW_ADD, m_buttonAdd);
  1850. DDX_Control(pDX, IDC_BUTTON_IPADDR_UP, m_buttonIpAddrUp);
  1851. DDX_Control(pDX, IDC_BUTTON_IPADDR_DOWN, m_buttonIpAddrDown);
  1852. //}}AFX_DATA_MAP
  1853. DDX_Control(pDX, IDC_IPADDR_DEFAULT_GW, m_ipaRouter);
  1854. }
  1855. BEGIN_MESSAGE_MAP(CScopeWizRouter, CPropertyPageBase)
  1856. //{{AFX_MSG_MAP(CScopeWizRouter)
  1857. ON_BN_CLICKED(IDC_BUTTON_DEFAULT_GW_ADD, OnButtonDefaultGwAdd)
  1858. ON_BN_CLICKED(IDC_BUTTON_DEFAULT_GW_DELETE, OnButtonDefaultGwDelete)
  1859. ON_LBN_SELCHANGE(IDC_LIST_DEFAULT_GW_LIST, OnSelchangeListDefaultGwList)
  1860. ON_EN_CHANGE(IDC_IPADDR_DEFAULT_GW, OnChangeRouter)
  1861. ON_WM_DESTROY()
  1862. //}}AFX_MSG_MAP
  1863. ON_BN_CLICKED(IDC_BUTTON_IPADDR_UP, OnButtonIpAddrUp)
  1864. ON_BN_CLICKED(IDC_BUTTON_IPADDR_DOWN, OnButtonIpAddrDown)
  1865. END_MESSAGE_MAP()
  1866. /////////////////////////////////////////////////////////////////////////////
  1867. // CScopeWizRouter message handlers
  1868. BOOL CScopeWizRouter::OnInitDialog()
  1869. {
  1870. CPropertyPageBase::OnInitDialog();
  1871. m_buttonDelete.EnableWindow(FALSE);
  1872. m_buttonAdd.EnableWindow(FALSE);
  1873. UpdateButtons();
  1874. return TRUE; // return TRUE unless you set the focus to a control
  1875. // EXCEPTION: OCX Property Pages should return FALSE
  1876. }
  1877. void CScopeWizRouter::OnDestroy()
  1878. {
  1879. CPropertyPageBase::OnDestroy();
  1880. }
  1881. LRESULT CScopeWizRouter::OnWizardNext()
  1882. {
  1883. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  1884. // now build the option info for the routers
  1885. if (m_listboxRouters.GetCount() == 0)
  1886. {
  1887. if (pScopeWiz->m_poptRouters)
  1888. {
  1889. delete pScopeWiz->m_poptRouters;
  1890. pScopeWiz->m_poptRouters = NULL;
  1891. }
  1892. }
  1893. else
  1894. {
  1895. // we have some DNS servers, get the option info from the master list and build an
  1896. // option info struct we can use later
  1897. CDhcpOption * pRoutersOption = pScopeWiz->m_pDefaultOptions->Find(DHCP_OPTION_ID_ROUTERS, NULL);
  1898. if (pRoutersOption)
  1899. {
  1900. CDhcpOption * pNewRouters;
  1901. if (pScopeWiz->m_poptRouters)
  1902. pNewRouters = pScopeWiz->m_poptRouters;
  1903. else
  1904. pNewRouters = new CDhcpOption(*pRoutersOption);
  1905. if (pNewRouters)
  1906. {
  1907. CDhcpOptionValue optValue = pNewRouters->QueryValue();
  1908. optValue.SetUpperBound(m_listboxRouters.GetCount());
  1909. // grab stuff from the listbox and store it in the option value
  1910. for (int i = 0; i < m_listboxRouters.GetCount(); i++)
  1911. {
  1912. DWORD dwIp = (DWORD) m_listboxRouters.GetItemData(i);
  1913. optValue.SetIpAddr(dwIp, i);
  1914. }
  1915. pNewRouters->Update(optValue);
  1916. pScopeWiz->m_poptRouters = pNewRouters;
  1917. }
  1918. }
  1919. }
  1920. return CPropertyPageBase::OnWizardNext();
  1921. }
  1922. LRESULT CScopeWizRouter::OnWizardBack()
  1923. {
  1924. return CPropertyPageBase::OnWizardBack();
  1925. }
  1926. BOOL CScopeWizRouter::OnSetActive()
  1927. {
  1928. return CPropertyPageBase::OnSetActive();
  1929. }
  1930. void CScopeWizRouter::OnButtonDefaultGwAdd()
  1931. {
  1932. DWORD dwIp;
  1933. m_ipaRouter.GetAddress(&dwIp);
  1934. if (dwIp)
  1935. {
  1936. CString strText;
  1937. UtilCvtIpAddrToWstr(dwIp, &strText);
  1938. int nIndex = m_listboxRouters.AddString(strText);
  1939. m_listboxRouters.SetItemData(nIndex, dwIp);
  1940. }
  1941. m_ipaRouter.ClearAddress();
  1942. m_ipaRouter.SetFocus();
  1943. }
  1944. void CScopeWizRouter::OnButtonDefaultGwDelete()
  1945. {
  1946. int nSel = m_listboxRouters.GetCurSel();
  1947. if (nSel != LB_ERR)
  1948. {
  1949. m_ipaRouter.SetAddress((DWORD)m_listboxRouters.GetItemData(nSel));
  1950. m_listboxRouters.DeleteString(nSel);
  1951. m_ipaRouter.SetFocus();
  1952. }
  1953. UpdateButtons();
  1954. }
  1955. void CScopeWizRouter::OnSelchangeListDefaultGwList()
  1956. {
  1957. UpdateButtons();
  1958. }
  1959. void CScopeWizRouter::OnChangeRouter()
  1960. {
  1961. UpdateButtons();
  1962. }
  1963. void CScopeWizRouter::UpdateButtons()
  1964. {
  1965. DWORD dwAddress;
  1966. BOOL bEnable;
  1967. m_ipaRouter.GetAddress(&dwAddress);
  1968. if (dwAddress)
  1969. {
  1970. bEnable = TRUE;
  1971. }
  1972. else
  1973. {
  1974. bEnable = FALSE;
  1975. if (m_buttonAdd.GetButtonStyle() & BS_DEFPUSHBUTTON)
  1976. {
  1977. m_buttonAdd.SetButtonStyle(BS_PUSHBUTTON);
  1978. }
  1979. }
  1980. m_buttonAdd.EnableWindow(bEnable);
  1981. if (m_listboxRouters.GetCurSel() != LB_ERR)
  1982. {
  1983. bEnable = TRUE;
  1984. }
  1985. else
  1986. {
  1987. bEnable = FALSE;
  1988. if (m_buttonDelete.GetButtonStyle() & BS_DEFPUSHBUTTON)
  1989. {
  1990. m_buttonDelete.SetButtonStyle(BS_PUSHBUTTON);
  1991. }
  1992. }
  1993. m_buttonDelete.EnableWindow(bEnable);
  1994. // up and down buttons
  1995. BOOL bEnableUp = (m_listboxRouters.GetCurSel() >= 0) && (m_listboxRouters.GetCurSel() != 0);
  1996. m_buttonIpAddrUp.EnableWindow(bEnableUp);
  1997. BOOL bEnableDown = (m_listboxRouters.GetCurSel() >= 0) && (m_listboxRouters.GetCurSel() < m_listboxRouters.GetCount() - 1);
  1998. m_buttonIpAddrDown.EnableWindow(bEnableDown);
  1999. }
  2000. void CScopeWizRouter::OnButtonIpAddrDown()
  2001. {
  2002. MoveValue(FALSE);
  2003. if (m_buttonIpAddrDown.IsWindowEnabled())
  2004. m_buttonIpAddrDown.SetFocus();
  2005. else
  2006. m_buttonIpAddrUp.SetFocus();
  2007. }
  2008. void CScopeWizRouter::OnButtonIpAddrUp()
  2009. {
  2010. MoveValue(TRUE);
  2011. if (m_buttonIpAddrUp.IsWindowEnabled())
  2012. m_buttonIpAddrUp.SetFocus();
  2013. else
  2014. m_buttonIpAddrDown.SetFocus();
  2015. }
  2016. void CScopeWizRouter::MoveValue(BOOL bUp)
  2017. {
  2018. // now get which item is selected in the listbox
  2019. int cFocus = m_listboxRouters.GetCurSel();
  2020. int cNewFocus;
  2021. DWORD err;
  2022. // make sure it's valid for this operation
  2023. if ( (bUp && cFocus <= 0) ||
  2024. (!bUp && cFocus >= m_listboxRouters.GetCount()) )
  2025. {
  2026. return;
  2027. }
  2028. // move the value up/down
  2029. CATCH_MEM_EXCEPTION
  2030. {
  2031. if (bUp)
  2032. {
  2033. cNewFocus = cFocus - 1;
  2034. }
  2035. else
  2036. {
  2037. cNewFocus = cFocus + 1;
  2038. }
  2039. // remove the old one
  2040. DWORD dwIp = (DWORD) m_listboxRouters.GetItemData(cFocus);
  2041. m_listboxRouters.DeleteString(cFocus);
  2042. // re-add it in it's new home
  2043. CString strText;
  2044. UtilCvtIpAddrToWstr(dwIp, &strText);
  2045. m_listboxRouters.InsertString(cNewFocus, strText);
  2046. m_listboxRouters.SetItemData(cNewFocus, dwIp);
  2047. m_listboxRouters.SetCurSel(cNewFocus);
  2048. }
  2049. END_MEM_EXCEPTION(err)
  2050. UpdateButtons();
  2051. }
  2052. /////////////////////////////////////////////////////////////////////////////
  2053. // CScopeWizDNS property page
  2054. IMPLEMENT_DYNCREATE(CScopeWizDNS, CPropertyPageBase)
  2055. CScopeWizDNS::CScopeWizDNS() : CPropertyPageBase(CScopeWizDNS::IDD)
  2056. {
  2057. //{{AFX_DATA_INIT(CScopeWizDNS)
  2058. //}}AFX_DATA_INIT
  2059. InitWiz97(FALSE, IDS_SCOPE_WIZ_DNS_TITLE, IDS_SCOPE_WIZ_DNS_SUBTITLE);
  2060. }
  2061. CScopeWizDNS::~CScopeWizDNS()
  2062. {
  2063. }
  2064. void CScopeWizDNS::DoDataExchange(CDataExchange* pDX)
  2065. {
  2066. CPropertyPageBase::DoDataExchange(pDX);
  2067. //{{AFX_DATA_MAP(CScopeWizDNS)
  2068. DDX_Control(pDX, IDC_EDIT_SERVER_NAME, m_editServerName);
  2069. DDX_Control(pDX, IDC_BUTTON_RESOLVE, m_buttonResolve);
  2070. DDX_Control(pDX, IDC_BUTTON_DNS_DELETE, m_buttonDelete);
  2071. DDX_Control(pDX, IDC_BUTTON_DNS_ADD, m_buttonAdd);
  2072. DDX_Control(pDX, IDC_EDIT_DOMAIN_NAME, m_editDomainName);
  2073. DDX_Control(pDX, IDC_LIST_DNS_LIST, m_listboxDNSServers);
  2074. DDX_Control(pDX, IDC_BUTTON_IPADDR_UP, m_buttonIpAddrUp);
  2075. DDX_Control(pDX, IDC_BUTTON_IPADDR_DOWN, m_buttonIpAddrDown);
  2076. //}}AFX_DATA_MAP
  2077. DDX_Control(pDX, IDC_IPADDR_DNS_SERVER, m_ipaDNS);
  2078. }
  2079. BEGIN_MESSAGE_MAP(CScopeWizDNS, CPropertyPageBase)
  2080. //{{AFX_MSG_MAP(CScopeWizDNS)
  2081. ON_BN_CLICKED(IDC_BUTTON_DNS_ADD, OnButtonDnsAdd)
  2082. ON_BN_CLICKED(IDC_BUTTON_DNS_DELETE, OnButtonDnsDelete)
  2083. ON_LBN_SELCHANGE(IDC_LIST_DNS_LIST, OnSelchangeListDnsList)
  2084. ON_EN_CHANGE(IDC_IPADDR_DNS_SERVER, OnChangeDnsServer)
  2085. ON_WM_DESTROY()
  2086. ON_EN_CHANGE(IDC_EDIT_SERVER_NAME, OnChangeEditServerName)
  2087. ON_BN_CLICKED(IDC_BUTTON_RESOLVE, OnButtonResolve)
  2088. //}}AFX_MSG_MAP
  2089. ON_BN_CLICKED(IDC_BUTTON_IPADDR_UP, OnButtonIpAddrUp)
  2090. ON_BN_CLICKED(IDC_BUTTON_IPADDR_DOWN, OnButtonIpAddrDown)
  2091. END_MESSAGE_MAP()
  2092. /////////////////////////////////////////////////////////////////////////////
  2093. // CScopeWizDNS message handlers
  2094. BOOL CScopeWizDNS::OnInitDialog()
  2095. {
  2096. CPropertyPageBase::OnInitDialog();
  2097. m_buttonDelete.EnableWindow(FALSE);
  2098. m_buttonAdd.EnableWindow(FALSE);
  2099. UpdateButtons();
  2100. return TRUE; // return TRUE unless you set the focus to a control
  2101. // EXCEPTION: OCX Property Pages should return FALSE
  2102. }
  2103. void CScopeWizDNS::OnDestroy()
  2104. {
  2105. CPropertyPageBase::OnDestroy();
  2106. }
  2107. LRESULT CScopeWizDNS::OnWizardNext()
  2108. {
  2109. // build the option stuff for the domain name
  2110. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  2111. CString strText;
  2112. m_editDomainName.GetWindowText(strText);
  2113. if (strText.IsEmpty())
  2114. {
  2115. if (pScopeWiz->m_poptDomainName)
  2116. {
  2117. delete pScopeWiz->m_poptDomainName;
  2118. pScopeWiz->m_poptDomainName = NULL;
  2119. }
  2120. }
  2121. else
  2122. {
  2123. // we have a domain name, get the option info from the master list and build an
  2124. // option info struct we can use later
  2125. CDhcpOption * pDomainNameOption = pScopeWiz->m_pDefaultOptions->Find(DHCP_OPTION_ID_DOMAIN_NAME, NULL);
  2126. if (pDomainNameOption)
  2127. {
  2128. CDhcpOption * pNewDomainName;
  2129. if (pScopeWiz->m_poptDomainName)
  2130. pNewDomainName = pScopeWiz->m_poptDomainName;
  2131. else
  2132. pNewDomainName = new CDhcpOption(*pDomainNameOption);
  2133. if (pNewDomainName)
  2134. {
  2135. CDhcpOptionValue optValue = pNewDomainName->QueryValue();
  2136. optValue.SetString(strText);
  2137. pNewDomainName->Update(optValue);
  2138. pScopeWiz->m_poptDomainName = pNewDomainName;
  2139. }
  2140. }
  2141. }
  2142. // now build the option info for the DNS servers
  2143. if (m_listboxDNSServers.GetCount() == 0)
  2144. {
  2145. if (pScopeWiz->m_poptDNSServers)
  2146. {
  2147. delete pScopeWiz->m_poptDNSServers;
  2148. pScopeWiz->m_poptDNSServers = NULL;
  2149. }
  2150. }
  2151. else
  2152. {
  2153. // we have some DNS servers, get the option info from the master list and build an
  2154. // option info struct we can use later
  2155. CDhcpOption * pDNSServersOption = pScopeWiz->m_pDefaultOptions->Find(DHCP_OPTION_ID_DNS_SERVERS, NULL);
  2156. if (pDNSServersOption)
  2157. {
  2158. CDhcpOption * pNewDNS;
  2159. if (pScopeWiz->m_poptDNSServers)
  2160. pNewDNS = pScopeWiz->m_poptDNSServers;
  2161. else
  2162. pNewDNS = new CDhcpOption(*pDNSServersOption);
  2163. if (pNewDNS)
  2164. {
  2165. CDhcpOptionValue optValue = pNewDNS->QueryValue();
  2166. optValue.SetUpperBound(m_listboxDNSServers.GetCount());
  2167. // grab stuff from the listbox and store it in the option value
  2168. for (int i = 0; i < m_listboxDNSServers.GetCount(); i++)
  2169. {
  2170. DWORD dwIp = (DWORD)m_listboxDNSServers.GetItemData(i);
  2171. optValue.SetIpAddr(dwIp, i);
  2172. }
  2173. pNewDNS->Update(optValue);
  2174. pScopeWiz->m_poptDNSServers = pNewDNS;
  2175. }
  2176. }
  2177. }
  2178. return CPropertyPageBase::OnWizardNext();
  2179. }
  2180. LRESULT CScopeWizDNS::OnWizardBack()
  2181. {
  2182. return CPropertyPageBase::OnWizardBack();
  2183. }
  2184. BOOL CScopeWizDNS::OnSetActive()
  2185. {
  2186. return CPropertyPageBase::OnSetActive();
  2187. }
  2188. void CScopeWizDNS::OnButtonDnsAdd()
  2189. {
  2190. DWORD dwIp;
  2191. m_ipaDNS.GetAddress(&dwIp);
  2192. if (dwIp)
  2193. {
  2194. CString strText;
  2195. UtilCvtIpAddrToWstr(dwIp, &strText);
  2196. int nIndex = m_listboxDNSServers.AddString(strText);
  2197. m_listboxDNSServers.SetItemData(nIndex, dwIp);
  2198. }
  2199. m_ipaDNS.ClearAddress();
  2200. m_ipaDNS.SetFocus();
  2201. }
  2202. void CScopeWizDNS::OnButtonDnsDelete()
  2203. {
  2204. int nSel = m_listboxDNSServers.GetCurSel();
  2205. if (nSel != LB_ERR)
  2206. {
  2207. m_ipaDNS.SetAddress((DWORD)m_listboxDNSServers.GetItemData(nSel));
  2208. m_listboxDNSServers.DeleteString(nSel);
  2209. m_ipaDNS.SetFocus();
  2210. }
  2211. UpdateButtons();
  2212. }
  2213. void CScopeWizDNS::OnSelchangeListDnsList()
  2214. {
  2215. UpdateButtons();
  2216. }
  2217. void CScopeWizDNS::OnChangeDnsServer()
  2218. {
  2219. UpdateButtons();
  2220. }
  2221. void CScopeWizDNS::UpdateButtons()
  2222. {
  2223. DWORD dwAddress;
  2224. BOOL bEnable;
  2225. CString strServerName;
  2226. // update the resolve button
  2227. m_editServerName.GetWindowText(strServerName);
  2228. m_buttonResolve.EnableWindow(strServerName.GetLength() > 0);
  2229. m_ipaDNS.GetAddress(&dwAddress);
  2230. if (dwAddress)
  2231. {
  2232. bEnable = TRUE;
  2233. }
  2234. else
  2235. {
  2236. bEnable = FALSE;
  2237. if (m_buttonAdd.GetButtonStyle() & BS_DEFPUSHBUTTON)
  2238. {
  2239. m_buttonAdd.SetButtonStyle(BS_PUSHBUTTON);
  2240. }
  2241. }
  2242. m_buttonAdd.EnableWindow(bEnable);
  2243. if (m_listboxDNSServers.GetCurSel() != LB_ERR)
  2244. {
  2245. bEnable = TRUE;
  2246. }
  2247. else
  2248. {
  2249. bEnable = FALSE;
  2250. if (m_buttonDelete.GetButtonStyle() & BS_DEFPUSHBUTTON)
  2251. {
  2252. m_buttonDelete.SetButtonStyle(BS_PUSHBUTTON);
  2253. }
  2254. }
  2255. m_buttonDelete.EnableWindow(bEnable);
  2256. // up and down buttons
  2257. BOOL bEnableUp = (m_listboxDNSServers.GetCurSel() >= 0) && (m_listboxDNSServers.GetCurSel() != 0);
  2258. m_buttonIpAddrUp.EnableWindow(bEnableUp);
  2259. BOOL bEnableDown = (m_listboxDNSServers.GetCurSel() >= 0) && (m_listboxDNSServers.GetCurSel() < m_listboxDNSServers.GetCount() - 1);
  2260. m_buttonIpAddrDown.EnableWindow(bEnableDown);
  2261. }
  2262. void CScopeWizDNS::OnButtonIpAddrDown()
  2263. {
  2264. MoveValue(FALSE);
  2265. if (m_buttonIpAddrDown.IsWindowEnabled())
  2266. m_buttonIpAddrDown.SetFocus();
  2267. else
  2268. m_buttonIpAddrUp.SetFocus();
  2269. }
  2270. void CScopeWizDNS::OnButtonIpAddrUp()
  2271. {
  2272. MoveValue(TRUE);
  2273. if (m_buttonIpAddrUp.IsWindowEnabled())
  2274. m_buttonIpAddrUp.SetFocus();
  2275. else
  2276. m_buttonIpAddrDown.SetFocus();
  2277. }
  2278. void CScopeWizDNS::MoveValue(BOOL bUp)
  2279. {
  2280. // now get which item is selected in the listbox
  2281. int cFocus = m_listboxDNSServers.GetCurSel();
  2282. int cNewFocus;
  2283. DWORD err;
  2284. // make sure it's valid for this operation
  2285. if ( (bUp && cFocus <= 0) ||
  2286. (!bUp && cFocus >= m_listboxDNSServers.GetCount()) )
  2287. {
  2288. return;
  2289. }
  2290. // move the value up/down
  2291. CATCH_MEM_EXCEPTION
  2292. {
  2293. if (bUp)
  2294. {
  2295. cNewFocus = cFocus - 1;
  2296. }
  2297. else
  2298. {
  2299. cNewFocus = cFocus + 1;
  2300. }
  2301. // remove the old one
  2302. DWORD dwIp = (DWORD) m_listboxDNSServers.GetItemData(cFocus);
  2303. m_listboxDNSServers.DeleteString(cFocus);
  2304. // re-add it in it's new home
  2305. CString strText;
  2306. UtilCvtIpAddrToWstr(dwIp, &strText);
  2307. m_listboxDNSServers.InsertString(cNewFocus, strText);
  2308. m_listboxDNSServers.SetItemData(cNewFocus, dwIp);
  2309. m_listboxDNSServers.SetCurSel(cNewFocus);
  2310. }
  2311. END_MEM_EXCEPTION(err)
  2312. UpdateButtons();
  2313. }
  2314. void CScopeWizDNS::OnChangeEditServerName()
  2315. {
  2316. UpdateButtons();
  2317. }
  2318. void CScopeWizDNS::OnButtonResolve()
  2319. {
  2320. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2321. CString strServer;
  2322. DHCP_IP_ADDRESS dhipa = 0;
  2323. DWORD err = 0;
  2324. m_editServerName.GetWindowText(strServer);
  2325. //
  2326. // See what type of name it is.
  2327. //
  2328. BEGIN_WAIT_CURSOR
  2329. switch (UtilCategorizeName(strServer))
  2330. {
  2331. case HNM_TYPE_IP:
  2332. dhipa = ::UtilCvtWstrToIpAddr( strServer ) ;
  2333. break ;
  2334. case HNM_TYPE_NB:
  2335. case HNM_TYPE_DNS:
  2336. err = ::UtilGetHostAddress( strServer, & dhipa ) ;
  2337. if (!err)
  2338. UtilCvtIpAddrToWstr(dhipa, &strServer);
  2339. break ;
  2340. default:
  2341. err = IDS_ERR_BAD_HOST_NAME ;
  2342. break ;
  2343. }
  2344. END_WAIT_CURSOR
  2345. if (err)
  2346. {
  2347. ::DhcpMessageBox(err);
  2348. }
  2349. else
  2350. {
  2351. m_ipaDNS.SetAddress(dhipa);
  2352. }
  2353. }
  2354. /////////////////////////////////////////////////////////////////////////////
  2355. // CScopeWizWINS property page
  2356. IMPLEMENT_DYNCREATE(CScopeWizWINS, CPropertyPageBase)
  2357. CScopeWizWINS::CScopeWizWINS() : CPropertyPageBase(CScopeWizWINS::IDD)
  2358. {
  2359. //{{AFX_DATA_INIT(CScopeWizWINS)
  2360. //}}AFX_DATA_INIT
  2361. InitWiz97(FALSE, IDS_SCOPE_WIZ_WINS_TITLE, IDS_SCOPE_WIZ_WINS_SUBTITLE);
  2362. }
  2363. CScopeWizWINS::~CScopeWizWINS()
  2364. {
  2365. }
  2366. void CScopeWizWINS::DoDataExchange(CDataExchange* pDX)
  2367. {
  2368. CPropertyPageBase::DoDataExchange(pDX);
  2369. //{{AFX_DATA_MAP(CScopeWizWINS)
  2370. DDX_Control(pDX, IDC_BUTTON_RESOLVE, m_buttonResolve);
  2371. DDX_Control(pDX, IDC_EDIT_SERVER_NAME, m_editServerName);
  2372. DDX_Control(pDX, IDC_LIST_WINS_LIST, m_listboxWINSServers);
  2373. DDX_Control(pDX, IDC_BUTTON_WINS_DELETE, m_buttonDelete);
  2374. DDX_Control(pDX, IDC_BUTTON_WINS_ADD, m_buttonAdd);
  2375. DDX_Control(pDX, IDC_BUTTON_IPADDR_UP, m_buttonIpAddrUp);
  2376. DDX_Control(pDX, IDC_BUTTON_IPADDR_DOWN, m_buttonIpAddrDown);
  2377. //}}AFX_DATA_MAP
  2378. DDX_Control(pDX, IDC_IPADDR_WINS_SERVER, m_ipaWINS);
  2379. }
  2380. BEGIN_MESSAGE_MAP(CScopeWizWINS, CPropertyPageBase)
  2381. //{{AFX_MSG_MAP(CScopeWizWINS)
  2382. ON_BN_CLICKED(IDC_BUTTON_WINS_ADD, OnButtonWinsAdd)
  2383. ON_BN_CLICKED(IDC_BUTTON_WINS_DELETE, OnButtonWinsDelete)
  2384. ON_LBN_SELCHANGE(IDC_LIST_WINS_LIST, OnSelchangeListWinsList)
  2385. ON_EN_CHANGE(IDC_IPADDR_WINS_SERVER, OnChangeWinsServer)
  2386. ON_WM_DESTROY()
  2387. ON_BN_CLICKED(IDC_BUTTON_RESOLVE, OnButtonResolve)
  2388. ON_EN_CHANGE(IDC_EDIT_SERVER_NAME, OnChangeEditServerName)
  2389. //}}AFX_MSG_MAP
  2390. ON_BN_CLICKED(IDC_BUTTON_IPADDR_UP, OnButtonIpAddrUp)
  2391. ON_BN_CLICKED(IDC_BUTTON_IPADDR_DOWN, OnButtonIpAddrDown)
  2392. END_MESSAGE_MAP()
  2393. /////////////////////////////////////////////////////////////////////////////
  2394. // CScopeWizWINS message handlers
  2395. BOOL CScopeWizWINS::OnInitDialog()
  2396. {
  2397. CPropertyPageBase::OnInitDialog();
  2398. m_buttonAdd.EnableWindow(FALSE);
  2399. m_buttonDelete.EnableWindow(FALSE);
  2400. UpdateButtons();
  2401. return TRUE; // return TRUE unless you set the focus to a control
  2402. // EXCEPTION: OCX Property Pages should return FALSE
  2403. }
  2404. void CScopeWizWINS::OnDestroy()
  2405. {
  2406. CPropertyPageBase::OnDestroy();
  2407. }
  2408. LRESULT CScopeWizWINS::OnWizardNext()
  2409. {
  2410. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  2411. // now build the option info for the routers
  2412. if (m_listboxWINSServers.GetCount() == 0)
  2413. {
  2414. // get rid of the servers option if it is there
  2415. if (pScopeWiz->m_poptWINSServers)
  2416. {
  2417. delete pScopeWiz->m_poptWINSServers;
  2418. pScopeWiz->m_poptWINSServers = NULL;
  2419. }
  2420. // get rid of the node type option as well
  2421. if (pScopeWiz->m_poptWINSNodeType)
  2422. {
  2423. delete pScopeWiz->m_poptWINSNodeType;
  2424. pScopeWiz->m_poptWINSNodeType = NULL;
  2425. }
  2426. }
  2427. else
  2428. {
  2429. // we have some DNS servers, get the option info from the master list and build an
  2430. // option info struct we can use later
  2431. CDhcpOption * pWINSServersOption = pScopeWiz->m_pDefaultOptions->Find(DHCP_OPTION_ID_WINS_SERVERS, NULL);
  2432. if (pWINSServersOption)
  2433. {
  2434. CDhcpOption * pNewWINS;
  2435. if (pScopeWiz->m_poptWINSServers)
  2436. pNewWINS = pScopeWiz->m_poptWINSServers;
  2437. else
  2438. pNewWINS = new CDhcpOption(*pWINSServersOption);
  2439. if (pNewWINS)
  2440. {
  2441. CDhcpOptionValue optValue = pNewWINS->QueryValue();
  2442. optValue.SetUpperBound(m_listboxWINSServers.GetCount());
  2443. // grab stuff from the listbox and store it in the option value
  2444. for (int i = 0; i < m_listboxWINSServers.GetCount(); i++)
  2445. {
  2446. DWORD dwIp = (DWORD)m_listboxWINSServers.GetItemData(i);
  2447. optValue.SetIpAddr(dwIp, i);
  2448. }
  2449. pNewWINS->Update(optValue);
  2450. pScopeWiz->m_poptWINSServers = pNewWINS;
  2451. }
  2452. }
  2453. // if we are configuring WINS, then we also need to set the node type option.
  2454. // we don't ask the user what type they want, the default should cover 95% of the cases
  2455. CDhcpOption * pNodeTypeOption = pScopeWiz->m_pDefaultOptions->Find(DHCP_OPTION_ID_WINS_NODE_TYPE, NULL);
  2456. if (pNodeTypeOption)
  2457. {
  2458. CDhcpOption * pNewNodeType;
  2459. if (pScopeWiz->m_poptWINSNodeType)
  2460. pNewNodeType = pScopeWiz->m_poptWINSNodeType;
  2461. else
  2462. pNewNodeType = new CDhcpOption(*pNodeTypeOption);
  2463. if (pNewNodeType)
  2464. {
  2465. CDhcpOptionValue optValue = pNewNodeType->QueryValue();
  2466. optValue.SetNumber(WINS_DEFAULT_NODE_TYPE);
  2467. pNewNodeType->Update(optValue);
  2468. pScopeWiz->m_poptWINSNodeType = pNewNodeType;
  2469. }
  2470. }
  2471. }
  2472. return CPropertyPageBase::OnWizardNext();
  2473. }
  2474. LRESULT CScopeWizWINS::OnWizardBack()
  2475. {
  2476. return CPropertyPageBase::OnWizardBack();
  2477. }
  2478. BOOL CScopeWizWINS::OnSetActive()
  2479. {
  2480. return CPropertyPageBase::OnSetActive();
  2481. }
  2482. void CScopeWizWINS::OnButtonWinsAdd()
  2483. {
  2484. DWORD dwIp;
  2485. m_ipaWINS.GetAddress(&dwIp);
  2486. if (dwIp)
  2487. {
  2488. CString strText;
  2489. UtilCvtIpAddrToWstr(dwIp, &strText);
  2490. int nIndex = m_listboxWINSServers.AddString(strText);
  2491. m_listboxWINSServers.SetItemData(nIndex, dwIp);
  2492. }
  2493. m_ipaWINS.ClearAddress();
  2494. m_ipaWINS.SetFocus();
  2495. }
  2496. void CScopeWizWINS::OnButtonWinsDelete()
  2497. {
  2498. int nSel = m_listboxWINSServers.GetCurSel();
  2499. if (nSel != LB_ERR)
  2500. {
  2501. m_ipaWINS.SetAddress((DWORD)m_listboxWINSServers.GetItemData(nSel));
  2502. m_listboxWINSServers.DeleteString(nSel);
  2503. m_ipaWINS.SetFocus();
  2504. }
  2505. UpdateButtons();
  2506. }
  2507. void CScopeWizWINS::OnSelchangeListWinsList()
  2508. {
  2509. UpdateButtons();
  2510. }
  2511. void CScopeWizWINS::OnChangeWinsServer()
  2512. {
  2513. UpdateButtons();
  2514. }
  2515. void CScopeWizWINS::UpdateButtons()
  2516. {
  2517. DWORD dwAddress;
  2518. BOOL bEnable;
  2519. CString strServerName;
  2520. // update the resolve button
  2521. m_editServerName.GetWindowText(strServerName);
  2522. m_buttonResolve.EnableWindow(strServerName.GetLength() > 0);
  2523. m_ipaWINS.GetAddress(&dwAddress);
  2524. if (dwAddress)
  2525. {
  2526. bEnable = TRUE;
  2527. }
  2528. else
  2529. {
  2530. bEnable = FALSE;
  2531. if (m_buttonAdd.GetButtonStyle() & BS_DEFPUSHBUTTON)
  2532. {
  2533. m_buttonAdd.SetButtonStyle(BS_PUSHBUTTON);
  2534. }
  2535. }
  2536. m_buttonAdd.EnableWindow(bEnable);
  2537. if (m_listboxWINSServers.GetCurSel() != LB_ERR)
  2538. {
  2539. bEnable = TRUE;
  2540. }
  2541. else
  2542. {
  2543. bEnable = FALSE;
  2544. if (m_buttonDelete.GetButtonStyle() & BS_DEFPUSHBUTTON)
  2545. {
  2546. m_buttonDelete.SetButtonStyle(BS_PUSHBUTTON);
  2547. }
  2548. }
  2549. m_buttonDelete.EnableWindow(bEnable);
  2550. // up and down buttons
  2551. BOOL bEnableUp = (m_listboxWINSServers.GetCurSel() >= 0) && (m_listboxWINSServers.GetCurSel() != 0);
  2552. m_buttonIpAddrUp.EnableWindow(bEnableUp);
  2553. BOOL bEnableDown = (m_listboxWINSServers.GetCurSel() >= 0) && (m_listboxWINSServers.GetCurSel() < m_listboxWINSServers.GetCount() - 1);
  2554. m_buttonIpAddrDown.EnableWindow(bEnableDown);
  2555. }
  2556. void CScopeWizWINS::OnButtonIpAddrDown()
  2557. {
  2558. MoveValue(FALSE);
  2559. if (m_buttonIpAddrDown.IsWindowEnabled())
  2560. m_buttonIpAddrDown.SetFocus();
  2561. else
  2562. m_buttonIpAddrUp.SetFocus();
  2563. }
  2564. void CScopeWizWINS::OnButtonIpAddrUp()
  2565. {
  2566. MoveValue(TRUE);
  2567. if (m_buttonIpAddrUp.IsWindowEnabled())
  2568. m_buttonIpAddrUp.SetFocus();
  2569. else
  2570. m_buttonIpAddrDown.SetFocus();
  2571. }
  2572. void CScopeWizWINS::MoveValue(BOOL bUp)
  2573. {
  2574. // now get which item is selected in the listbox
  2575. int cFocus = m_listboxWINSServers.GetCurSel();
  2576. int cNewFocus;
  2577. DWORD err;
  2578. // make sure it's valid for this operation
  2579. if ( (bUp && cFocus <= 0) ||
  2580. (!bUp && cFocus >= m_listboxWINSServers.GetCount()) )
  2581. {
  2582. return;
  2583. }
  2584. // move the value up/down
  2585. CATCH_MEM_EXCEPTION
  2586. {
  2587. if (bUp)
  2588. {
  2589. cNewFocus = cFocus - 1;
  2590. }
  2591. else
  2592. {
  2593. cNewFocus = cFocus + 1;
  2594. }
  2595. // remove the old one
  2596. DWORD dwIp = (DWORD) m_listboxWINSServers.GetItemData(cFocus);
  2597. m_listboxWINSServers.DeleteString(cFocus);
  2598. // re-add it in it's new home
  2599. CString strText;
  2600. UtilCvtIpAddrToWstr(dwIp, &strText);
  2601. m_listboxWINSServers.InsertString(cNewFocus, strText);
  2602. m_listboxWINSServers.SetItemData(cNewFocus, dwIp);
  2603. m_listboxWINSServers.SetCurSel(cNewFocus);
  2604. }
  2605. END_MEM_EXCEPTION(err)
  2606. UpdateButtons();
  2607. }
  2608. void CScopeWizWINS::OnButtonResolve()
  2609. {
  2610. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2611. CString strServer;
  2612. DHCP_IP_ADDRESS dhipa = 0;
  2613. DWORD err = 0;
  2614. m_editServerName.GetWindowText(strServer);
  2615. //
  2616. // See what type of name it is.
  2617. //
  2618. BEGIN_WAIT_CURSOR
  2619. switch (UtilCategorizeName(strServer))
  2620. {
  2621. case HNM_TYPE_IP:
  2622. dhipa = ::UtilCvtWstrToIpAddr( strServer ) ;
  2623. break ;
  2624. case HNM_TYPE_NB:
  2625. case HNM_TYPE_DNS:
  2626. err = ::UtilGetHostAddress( strServer, & dhipa ) ;
  2627. if (!err)
  2628. UtilCvtIpAddrToWstr(dhipa, &strServer);
  2629. break ;
  2630. default:
  2631. err = IDS_ERR_BAD_HOST_NAME ;
  2632. break ;
  2633. }
  2634. END_WAIT_CURSOR
  2635. if (err)
  2636. {
  2637. ::DhcpMessageBox(err);
  2638. }
  2639. else
  2640. {
  2641. m_ipaWINS.SetAddress(dhipa);
  2642. }
  2643. }
  2644. void CScopeWizWINS::OnChangeEditServerName()
  2645. {
  2646. UpdateButtons();
  2647. }
  2648. /////////////////////////////////////////////////////////////////////////////
  2649. // CScopeWizActivate property page
  2650. IMPLEMENT_DYNCREATE(CScopeWizActivate, CPropertyPageBase)
  2651. CScopeWizActivate::CScopeWizActivate() : CPropertyPageBase(CScopeWizActivate::IDD)
  2652. {
  2653. //{{AFX_DATA_INIT(CScopeWizActivate)
  2654. // NOTE: the ClassWizard will add member initialization here
  2655. //}}AFX_DATA_INIT
  2656. InitWiz97(FALSE, IDS_SCOPE_WIZ_ACTIVATE_TITLE, IDS_SCOPE_WIZ_ACTIVATE_SUBTITLE);
  2657. }
  2658. CScopeWizActivate::~CScopeWizActivate()
  2659. {
  2660. }
  2661. void CScopeWizActivate::DoDataExchange(CDataExchange* pDX)
  2662. {
  2663. CPropertyPageBase::DoDataExchange(pDX);
  2664. //{{AFX_DATA_MAP(CScopeWizActivate)
  2665. // NOTE: the ClassWizard will add DDX and DDV calls here
  2666. //}}AFX_DATA_MAP
  2667. }
  2668. BEGIN_MESSAGE_MAP(CScopeWizActivate, CPropertyPageBase)
  2669. //{{AFX_MSG_MAP(CScopeWizActivate)
  2670. //}}AFX_MSG_MAP
  2671. END_MESSAGE_MAP()
  2672. /////////////////////////////////////////////////////////////////////////////
  2673. // CScopeWizActivate message handlers
  2674. BOOL CScopeWizActivate::OnInitDialog()
  2675. {
  2676. CPropertyPageBase::OnInitDialog();
  2677. ((CButton *) GetDlgItem(IDC_RADIO_YES))->SetCheck(TRUE);
  2678. return TRUE; // return TRUE unless you set the focus to a control
  2679. // EXCEPTION: OCX Property Pages should return FALSE
  2680. }
  2681. LRESULT CScopeWizActivate::OnWizardNext()
  2682. {
  2683. CScopeWiz * pScopeWiz = reinterpret_cast<CScopeWiz *>(GetHolder());
  2684. pScopeWiz->m_fActivateScope = (((CButton *) GetDlgItem(IDC_RADIO_YES))->GetCheck()) ? TRUE : FALSE;
  2685. return CPropertyPageBase::OnWizardNext();
  2686. }
  2687. LRESULT CScopeWizActivate::OnWizardBack()
  2688. {
  2689. // TODO: Add your specialized code here and/or call the base class
  2690. return CPropertyPageBase::OnWizardBack();
  2691. }
  2692. BOOL CScopeWizActivate::OnSetActive()
  2693. {
  2694. GetHolder()->SetWizardButtonsMiddle(TRUE);
  2695. return CPropertyPageBase::OnSetActive();
  2696. }