Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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