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.

673 lines
18 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. MScopePP.cpp
  7. This file contains all of the implementation for the
  8. scope property page.
  9. FILE HISTORY:
  10. */
  11. #include "stdafx.h"
  12. #include "nodes.h"
  13. #include "mscopepp.h"
  14. #include "mscope.h"
  15. #include "server.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. //
  23. // CMScopeProperties holder
  24. //
  25. /////////////////////////////////////////////////////////////////////////////
  26. CMScopeProperties::CMScopeProperties
  27. (
  28. ITFSNode * pNode,
  29. IComponentData * pComponentData,
  30. ITFSComponentData * pTFSCompData,
  31. LPCTSTR pszSheetName
  32. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  33. {
  34. //ASSERT(pFolderNode == GetContainerNode());
  35. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  36. m_liVersion.QuadPart = 0;
  37. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  38. AddPageToList((CPropertyPageBase*) &m_pageLifetime);
  39. Assert(pTFSCompData != NULL);
  40. m_spTFSCompData.Set(pTFSCompData);
  41. }
  42. CMScopeProperties::~CMScopeProperties()
  43. {
  44. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  45. RemovePageFromList((CPropertyPageBase*) &m_pageLifetime, FALSE);
  46. }
  47. void
  48. CMScopeProperties::SetVersion
  49. (
  50. LARGE_INTEGER & liVersion
  51. )
  52. {
  53. m_liVersion = liVersion;
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CScopePropGeneral property page
  57. IMPLEMENT_DYNCREATE(CMScopePropGeneral, CPropertyPageBase)
  58. CMScopePropGeneral::CMScopePropGeneral() : CPropertyPageBase(CMScopePropGeneral::IDD)
  59. {
  60. //{{AFX_DATA_INIT(CMScopePropGeneral)
  61. m_strComment = _T("");
  62. m_strName = _T("");
  63. //}}AFX_DATA_INIT
  64. m_bUpdateInfo = FALSE;
  65. m_bUpdateLease = FALSE;
  66. m_bUpdateRange = FALSE;
  67. m_bUpdateTTL = FALSE;
  68. m_uImage = 0;
  69. }
  70. CMScopePropGeneral::~CMScopePropGeneral()
  71. {
  72. }
  73. void CMScopePropGeneral::DoDataExchange(CDataExchange* pDX)
  74. {
  75. CPropertyPageBase::DoDataExchange(pDX);
  76. //{{AFX_DATA_MAP(CMScopePropGeneral)
  77. DDX_Control(pDX, IDC_EDIT_SCOPE_NAME, m_editName);
  78. DDX_Control(pDX, IDC_EDIT_SCOPE_COMMENT, m_editComment);
  79. DDX_Control(pDX, IDC_EDIT_TTL, m_editTTL);
  80. DDX_Control(pDX, IDC_RADIO_LEASE_UNLIMITED, m_radioUnlimited);
  81. DDX_Control(pDX, IDC_RADIO_LEASE_LIMITED, m_radioLimited);
  82. DDX_Control(pDX, IDC_EDIT_LEASE_MINUTES, m_editMinutes);
  83. DDX_Control(pDX, IDC_EDIT_LEASE_HOURS, m_editHours);
  84. DDX_Control(pDX, IDC_EDIT_LEASE_DAYS, m_editDays);
  85. DDX_Control(pDX, IDC_SPIN_TTL, m_spinTTL);
  86. DDX_Control(pDX, IDC_SPIN_LEASE_HOURS, m_spinHours);
  87. DDX_Control(pDX, IDC_SPIN_LEASE_MINUTES, m_spinMinutes);
  88. DDX_Control(pDX, IDC_SPIN_LEASE_DAYS, m_spinDays);
  89. DDX_Text(pDX, IDC_EDIT_SCOPE_COMMENT, m_strComment);
  90. DDX_Text(pDX, IDC_EDIT_SCOPE_NAME, m_strName);
  91. //}}AFX_DATA_MAP
  92. DDX_Control(pDX, IDC_IPADDR_START, m_ipaStart);
  93. DDX_Control(pDX, IDC_IPADDR_END, m_ipaEnd);
  94. }
  95. BEGIN_MESSAGE_MAP(CMScopePropGeneral, CPropertyPageBase)
  96. //{{AFX_MSG_MAP(CMScopePropGeneral)
  97. ON_BN_CLICKED(IDC_RADIO_LEASE_LIMITED, OnRadioLeaseLimited)
  98. ON_BN_CLICKED(IDC_RADIO_LEASE_UNLIMITED, OnRadioLeaseUnlimited)
  99. ON_EN_CHANGE(IDC_EDIT_LEASE_DAYS, OnChangeEditLeaseDays)
  100. ON_EN_CHANGE(IDC_EDIT_LEASE_HOURS, OnChangeEditLeaseHours)
  101. ON_EN_CHANGE(IDC_EDIT_LEASE_MINUTES, OnChangeEditLeaseMinutes)
  102. ON_EN_CHANGE(IDC_EDIT_TTL, OnChangeEditTTL)
  103. ON_EN_CHANGE(IDC_EDIT_SCOPE_COMMENT, OnChangeEditScopeComment)
  104. ON_EN_CHANGE(IDC_EDIT_SCOPE_NAME, OnChangeEditScopeName)
  105. //}}AFX_MSG_MAP
  106. ON_EN_CHANGE(IDC_IPADDR_START, OnChangeIpAddrStart)
  107. ON_EN_CHANGE(IDC_IPADDR_END, OnChangeIpAddrStart)
  108. END_MESSAGE_MAP()
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CMScopePropGeneral message handlers
  111. BOOL CMScopePropGeneral::OnInitDialog()
  112. {
  113. CPropertyPageBase::OnInitDialog();
  114. m_ipaStart.SetAddress(m_ScopeCfg.m_dwStartAddress);
  115. m_ipaEnd.SetAddress(m_ScopeCfg.m_dwEndAddress);
  116. m_spinMinutes.SetRange(0, 59);
  117. m_spinHours.SetRange(0, 23);
  118. m_spinDays.SetRange(0, 999);
  119. m_editMinutes.LimitText(2);
  120. m_editHours.LimitText(2);
  121. m_editDays.LimitText(3);
  122. // Limit the name and comment field to 255 chars
  123. CEdit *pEditName = reinterpret_cast<CEdit *>(GetDlgItem( IDC_EDIT_SCOPE_NAME ));
  124. if ( 0 != pEditName ) {
  125. pEditName->LimitText( MAX_NAME_LENGTH ); // max characters for superscope name
  126. }
  127. CEdit *pEditComment = reinterpret_cast<CEdit *>(GetDlgItem( IDC_EDIT_SCOPE_COMMENT ));
  128. if ( 0 != pEditComment ) {
  129. pEditComment->LimitText( MAX_NAME_LENGTH ); // max characters for superscope name
  130. }
  131. // fill in the name & comment
  132. m_editName.SetWindowText(m_SubnetInfo.SubnetName);
  133. m_editComment.SetWindowText(m_SubnetInfo.SubnetComment);
  134. // fill in lease time info
  135. if (m_ScopeCfg.m_dwLeaseTime != DHCP_INFINIT_LEASE)
  136. {
  137. int nDays, nHours, nMinutes;
  138. UtilConvertLeaseTime(m_ScopeCfg.m_dwLeaseTime, &nDays, &nHours, &nMinutes);
  139. m_spinDays.SetPos(nDays);
  140. m_spinHours.SetPos(nHours);
  141. m_spinMinutes.SetPos(nMinutes);
  142. }
  143. // setup the lease time controls
  144. ActivateDuration (m_ScopeCfg.m_dwLeaseTime != DHCP_INFINIT_LEASE);
  145. m_radioUnlimited.SetCheck(m_ScopeCfg.m_dwLeaseTime == DHCP_INFINIT_LEASE);
  146. m_radioLimited.SetCheck(m_ScopeCfg.m_dwLeaseTime != DHCP_INFINIT_LEASE);
  147. // set the ttl
  148. m_spinTTL.SetRange(1, 255);
  149. m_spinTTL.SetPos(m_SubnetInfo.TTL);
  150. // load the correct icon
  151. for (int i = 0; i < ICON_IDX_MAX; i++)
  152. {
  153. if (g_uIconMap[i][1] == m_uImage)
  154. {
  155. HICON hIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(g_uIconMap[i][0]));
  156. if (hIcon)
  157. ((CStatic *) GetDlgItem(IDC_STATIC_ICON))->SetIcon(hIcon);
  158. break;
  159. }
  160. }
  161. SetDirty(FALSE);
  162. return TRUE; // return TRUE unless you set the focus to a control
  163. // EXCEPTION: OCX Property Pages should return FALSE
  164. }
  165. void CMScopePropGeneral::OnRadioLeaseLimited()
  166. {
  167. ActivateDuration(TRUE);
  168. SetDirty(TRUE);
  169. }
  170. void CMScopePropGeneral::OnRadioLeaseUnlimited()
  171. {
  172. ActivateDuration(FALSE);
  173. SetDirty(TRUE);
  174. }
  175. BOOL CMScopePropGeneral::OnApply()
  176. {
  177. // this gets the name and comment
  178. UpdateData();
  179. // grab the lease time
  180. DWORD dwLeaseTime;
  181. if (m_radioUnlimited.GetCheck())
  182. {
  183. dwLeaseTime = DHCP_INFINIT_LEASE;
  184. }
  185. else
  186. {
  187. dwLeaseTime = UtilConvertLeaseTime(m_spinDays.GetPos(),
  188. m_spinHours.GetPos(),
  189. m_spinMinutes.GetPos());
  190. }
  191. if (dwLeaseTime == 0)
  192. {
  193. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  194. DhcpMessageBox(IDS_ERR_NO_DURATION_SPECIFIED);
  195. m_editDays.SetFocus();
  196. return FALSE;
  197. }
  198. if (dwLeaseTime != m_ScopeCfg.m_dwLeaseTime)
  199. {
  200. m_bUpdateLease = TRUE;
  201. m_ScopeCfgTemp.m_dwLeaseTime = dwLeaseTime;
  202. }
  203. m_bUpdateInfo = (m_editName.GetModify() || m_editComment.GetModify());
  204. // grab the TTL
  205. CString strTemp;
  206. DWORD dwTemp;
  207. m_editTTL.GetWindowText(strTemp);
  208. FCvtAsciiToInteger((LPCTSTR) strTemp, &dwTemp);
  209. m_SubnetInfoTemp.TTL = LOBYTE(LOWORD(dwTemp));
  210. if ( (dwTemp < 1) ||
  211. (dwTemp > 255) )
  212. {
  213. // invalid TTL specified
  214. AfxMessageBox(IDS_INVALID_TTL);
  215. m_editTTL.SetFocus();
  216. m_editTTL.SetSel(0,-1);
  217. return FALSE;
  218. }
  219. if (m_SubnetInfo.TTL != m_SubnetInfoTemp.TTL)
  220. {
  221. m_bUpdateInfo = TRUE;
  222. }
  223. // grab the addresses
  224. if (m_ipaStart.GetModify() ||
  225. m_ipaEnd.GetModify() )
  226. {
  227. m_bUpdateRange = TRUE;
  228. m_ipaStart.GetAddress(&m_ScopeCfgTemp.m_dwStartAddress);
  229. m_ipaEnd.GetAddress(&m_ScopeCfgTemp.m_dwEndAddress);
  230. }
  231. // call the base on apply which does the thread switch for us
  232. // and we come back through OnPropertyChange
  233. BOOL bRet = CPropertyPageBase::OnApply();
  234. if (bRet == FALSE)
  235. {
  236. // Something bad happened... grab the error code
  237. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  238. ::DhcpMessageBox(GetHolder()->GetError());
  239. }
  240. m_editName.SetModify(FALSE);
  241. m_editComment.SetModify(FALSE);
  242. m_editTTL.SetModify(FALSE);
  243. return bRet;
  244. }
  245. BOOL CMScopePropGeneral::OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask)
  246. {
  247. CDhcpMScope * pScope;
  248. SPITFSNode spNode;
  249. DWORD dwError = 0;
  250. spNode = GetHolder()->GetNode();
  251. pScope = GETHANDLER(CDhcpMScope, spNode);
  252. BEGIN_WAIT_CURSOR;
  253. //
  254. // Check to see if we need to update the least time
  255. //
  256. if (m_bUpdateLease)
  257. {
  258. // Lease time changed, update on server
  259. dwError = pScope->SetLeaseTime(m_ScopeCfgTemp.m_dwLeaseTime);
  260. if (dwError != ERROR_SUCCESS)
  261. {
  262. GetHolder()->SetError(dwError);
  263. }
  264. else
  265. {
  266. m_ScopeCfg.m_dwLeaseTime = m_ScopeCfgTemp.m_dwLeaseTime;
  267. m_bUpdateLease = FALSE;
  268. }
  269. }
  270. //
  271. // Now check the allocation range
  272. //
  273. if (m_bUpdateRange)
  274. {
  275. // need to update the address pool allocation range
  276. DHCP_IP_RANGE dhcpIpRange;
  277. dhcpIpRange.StartAddress = m_ScopeCfgTemp.m_dwStartAddress;
  278. dhcpIpRange.EndAddress = m_ScopeCfgTemp.m_dwEndAddress;
  279. dwError = pScope->UpdateIpRange(&dhcpIpRange);
  280. if (dwError != ERROR_SUCCESS)
  281. {
  282. GetHolder()->SetError(dwError);
  283. }
  284. else
  285. {
  286. m_ScopeCfg.m_dwStartAddress = m_ScopeCfgTemp.m_dwStartAddress;
  287. m_ScopeCfg.m_dwEndAddress = m_ScopeCfgTemp.m_dwEndAddress;
  288. m_bUpdateRange = FALSE;
  289. }
  290. }
  291. //
  292. // Update the name and comment if necessary
  293. //
  294. LPCTSTR pNewName = NULL;
  295. CString strDisplay, strOldComment;
  296. strOldComment = pScope->GetComment();
  297. if (m_bUpdateInfo)
  298. {
  299. // update the comment
  300. m_SubnetInfoTemp.SubnetComment = m_strComment;
  301. pScope->SetComment(m_strComment);
  302. // name
  303. m_SubnetInfoTemp.SubnetName = m_strName;
  304. pNewName = (LPCTSTR) m_strName;
  305. *ChangeMask = SCOPE_PANE_CHANGE_ITEM_DATA;
  306. // Lease time changed, update on server
  307. dwError = pScope->SetTTL(m_SubnetInfoTemp.TTL);
  308. // try to set the new info
  309. dwError = pScope->SetInfo(pNewName);
  310. if (dwError != ERROR_SUCCESS)
  311. {
  312. // failed, revert to old info
  313. pScope->SetComment(strOldComment);
  314. GetHolder()->SetError(dwError);
  315. }
  316. else
  317. {
  318. // success, rebuild display name
  319. pScope->BuildDisplayName(&strDisplay, pNewName);
  320. pScope->SetDisplayName(strDisplay);
  321. m_SubnetInfo = m_SubnetInfoTemp;
  322. m_bUpdateInfo = FALSE;
  323. }
  324. }
  325. END_WAIT_CURSOR;
  326. return FALSE;
  327. }
  328. void CMScopePropGeneral::OnChangeEditLeaseDays()
  329. {
  330. ValidateLeaseTime();
  331. SetDirty(TRUE);
  332. }
  333. void CMScopePropGeneral::OnChangeEditLeaseHours()
  334. {
  335. ValidateLeaseTime();
  336. SetDirty(TRUE);
  337. }
  338. void CMScopePropGeneral::OnChangeEditLeaseMinutes()
  339. {
  340. ValidateLeaseTime();
  341. SetDirty(TRUE);
  342. }
  343. void CMScopePropGeneral::OnChangeEditTTL()
  344. {
  345. SetDirty(TRUE);
  346. }
  347. void CMScopePropGeneral::OnChangeEditScopeComment()
  348. {
  349. SetDirty(TRUE);
  350. }
  351. void CMScopePropGeneral::OnChangeEditScopeName()
  352. {
  353. SetDirty(TRUE);
  354. }
  355. void CMScopePropGeneral::OnChangeIpAddrStart()
  356. {
  357. SetDirty(TRUE);
  358. }
  359. void CMScopePropGeneral::OnChangeIpAddrEnd()
  360. {
  361. SetDirty(TRUE);
  362. }
  363. //
  364. // Helpers
  365. //
  366. void
  367. CMScopePropGeneral::ActivateDuration
  368. (
  369. BOOL fActive
  370. )
  371. {
  372. m_spinMinutes.EnableWindow(fActive);
  373. m_spinHours.EnableWindow(fActive);
  374. m_spinDays.EnableWindow(fActive);
  375. m_editMinutes.EnableWindow(fActive);
  376. m_editHours.EnableWindow(fActive);
  377. m_editDays.EnableWindow(fActive);
  378. GetDlgItem(IDC_STATIC_DAYS)->EnableWindow(fActive);
  379. GetDlgItem(IDC_STATIC_HOURS)->EnableWindow(fActive);
  380. GetDlgItem(IDC_STATIC_MINUTES)->EnableWindow(fActive);
  381. }
  382. void
  383. CMScopePropGeneral::ValidateLeaseTime()
  384. {
  385. CString strText;
  386. if (IsWindow(m_editHours.GetSafeHwnd()))
  387. {
  388. m_editHours.GetWindowText(strText);
  389. // check to see if the value is greater than the max
  390. if (_ttoi(strText) > HOURS_MAX)
  391. {
  392. LPTSTR pBuf = strText.GetBuffer(5);
  393. _itot(HOURS_MAX, pBuf, 10);
  394. strText.ReleaseBuffer();
  395. m_editHours.SetWindowText(strText);
  396. m_spinHours.SetPos(HOURS_MAX);
  397. MessageBeep(MB_ICONEXCLAMATION);
  398. }
  399. }
  400. if (IsWindow(m_editMinutes.GetSafeHwnd()))
  401. {
  402. m_editMinutes.GetWindowText(strText);
  403. // check to see if the value is greater than the max
  404. if (_ttoi(strText) > MINUTES_MAX)
  405. {
  406. LPTSTR pBuf = strText.GetBuffer(5);
  407. _itot(MINUTES_MAX, pBuf, 10);
  408. strText.ReleaseBuffer();
  409. m_editMinutes.SetWindowText(strText);
  410. m_spinMinutes.SetPos(MINUTES_MAX);
  411. MessageBeep(MB_ICONEXCLAMATION);
  412. }
  413. }
  414. }
  415. /////////////////////////////////////////////////////////////////////////////
  416. // CMScopePropLifetime property page
  417. IMPLEMENT_DYNCREATE(CMScopePropLifetime, CPropertyPageBase)
  418. CMScopePropLifetime::CMScopePropLifetime() : CPropertyPageBase(CMScopePropLifetime::IDD)
  419. {
  420. //{{AFX_DATA_INIT(CMScopePropLifetime)
  421. //}}AFX_DATA_INIT
  422. m_Expiry.dwLowDateTime = DHCP_DATE_TIME_INFINIT_LOW;
  423. m_Expiry.dwHighDateTime = DHCP_DATE_TIME_INFINIT_HIGH;
  424. }
  425. CMScopePropLifetime::~CMScopePropLifetime()
  426. {
  427. }
  428. void CMScopePropLifetime::DoDataExchange(CDataExchange* pDX)
  429. {
  430. CPropertyPageBase::DoDataExchange(pDX);
  431. //{{AFX_DATA_MAP(CMScopePropLifetime)
  432. DDX_Control(pDX, IDC_RADIO_MSCOPE_FINITE, m_radioFinite);
  433. DDX_Control(pDX, IDC_RADIO_MSCOPE_INFINITE, m_radioInfinite);
  434. //}}AFX_DATA_MAP
  435. }
  436. BEGIN_MESSAGE_MAP(CMScopePropLifetime, CPropertyPageBase)
  437. //{{AFX_MSG_MAP(CMScopePropLifetime)
  438. ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER_TIME, OnDatetimechangeDatetimepickerTime)
  439. ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER_DATE, OnDatetimechangeDatetimepickerDate)
  440. ON_BN_CLICKED(IDC_RADIO_MSCOPE_INFINITE, OnRadioScopeInfinite)
  441. ON_BN_CLICKED(IDC_RADIO_MSCOPE_FINITE, OnRadioMscopeFinite)
  442. //}}AFX_MSG_MAP
  443. END_MESSAGE_MAP()
  444. /////////////////////////////////////////////////////////////////////////////
  445. // CMScopePropLifetime message handlers
  446. BOOL CMScopePropLifetime::OnInitDialog()
  447. {
  448. CPropertyPageBase::OnInitDialog();
  449. if ( (m_Expiry.dwLowDateTime == DHCP_DATE_TIME_INFINIT_LOW) &&
  450. (m_Expiry.dwHighDateTime == DHCP_DATE_TIME_INFINIT_HIGH) )
  451. {
  452. m_radioInfinite.SetCheck(TRUE);
  453. }
  454. else
  455. {
  456. SYSTEMTIME st;
  457. FILETIME ft;
  458. m_radioFinite.SetCheck(TRUE);
  459. FileTimeToLocalFileTime((FILETIME *) &m_Expiry, &ft);
  460. FileTimeToSystemTime(&ft, &st);
  461. ::SendMessage(GetDlgItem(IDC_DATETIMEPICKER_DATE)->GetSafeHwnd(), DTM_SETSYSTEMTIME, 0, (LPARAM) &st);
  462. ::SendMessage(GetDlgItem(IDC_DATETIMEPICKER_TIME)->GetSafeHwnd(), DTM_SETSYSTEMTIME, 0, (LPARAM) &st);
  463. }
  464. UpdateControls();
  465. SetDirty(FALSE);
  466. return TRUE; // return TRUE unless you set the focus to a control
  467. // EXCEPTION: OCX Property Pages should return FALSE
  468. }
  469. BOOL CMScopePropLifetime::OnApply()
  470. {
  471. DATE_TIME datetime;
  472. if (m_radioInfinite.GetCheck())
  473. {
  474. datetime.dwLowDateTime = DHCP_DATE_TIME_INFINIT_LOW;
  475. datetime.dwHighDateTime = DHCP_DATE_TIME_INFINIT_HIGH;
  476. }
  477. else
  478. {
  479. SYSTEMTIME stDate, stTime;
  480. ::SendMessage(GetDlgItem(IDC_DATETIMEPICKER_DATE)->GetSafeHwnd(), DTM_GETSYSTEMTIME, 0, (LPARAM) &stDate);
  481. ::SendMessage(GetDlgItem(IDC_DATETIMEPICKER_TIME)->GetSafeHwnd(), DTM_GETSYSTEMTIME, 0, (LPARAM) &stTime);
  482. SYSTEMTIME systemtime;
  483. systemtime.wYear = stDate.wYear;
  484. systemtime.wMonth = stDate.wMonth;
  485. systemtime.wDayOfWeek = stDate.wDayOfWeek;
  486. systemtime.wDay = stDate.wDay;
  487. systemtime.wHour = stTime.wHour;
  488. systemtime.wMinute = stTime.wMinute;
  489. systemtime.wSecond = stTime.wSecond;
  490. systemtime.wMilliseconds = 0;
  491. FILETIME ft;
  492. ::SystemTimeToFileTime(&systemtime, &ft);
  493. ::LocalFileTimeToFileTime(&ft, (LPFILETIME) &datetime);
  494. }
  495. CDhcpMScope * pScope;
  496. SPITFSNode spNode;
  497. DWORD dwError = 0;
  498. spNode = GetHolder()->GetNode();
  499. pScope = GETHANDLER(CDhcpMScope, spNode);
  500. pScope->SetLifetime(&datetime);
  501. dwError = pScope->SetInfo(NULL);
  502. if (dwError != ERROR_SUCCESS)
  503. {
  504. DhcpMessageBox(dwError);
  505. return FALSE;
  506. }
  507. return CPropertyPageBase::OnApply();
  508. }
  509. void CMScopePropLifetime::UpdateControls()
  510. {
  511. BOOL fEnable = TRUE;
  512. if (m_radioInfinite.GetCheck())
  513. {
  514. fEnable = FALSE;
  515. }
  516. GetDlgItem(IDC_DATETIMEPICKER_DATE)->EnableWindow(fEnable);
  517. GetDlgItem(IDC_DATETIMEPICKER_TIME)->EnableWindow(fEnable);
  518. }
  519. void CMScopePropLifetime::OnDatetimechangeDatetimepickerTime(NMHDR* pNMHDR, LRESULT* pResult)
  520. {
  521. SetDirty(TRUE);
  522. *pResult = 0;
  523. }
  524. void CMScopePropLifetime::OnDatetimechangeDatetimepickerDate(NMHDR* pNMHDR, LRESULT* pResult)
  525. {
  526. SetDirty(TRUE);
  527. *pResult = 0;
  528. }
  529. void CMScopePropLifetime::OnRadioScopeInfinite()
  530. {
  531. SetDirty(TRUE);
  532. UpdateControls();
  533. }
  534. void CMScopePropLifetime::OnRadioMscopeFinite()
  535. {
  536. SetDirty(TRUE);
  537. UpdateControls();
  538. }