Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

643 lines
19 KiB

  1. /*======================================================================================//
  2. | Process Control //
  3. | //
  4. |Copyright (c) 1998 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: RootPages.cpp //
  7. | //
  8. |Description: Property page implemention for the root node //
  9. | //
  10. |Created: Paul Skoglund 10-1998 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #include "StdAfx.h"
  16. #include "BaseNode.h"
  17. #include "shlobj.h"
  18. #include "RootPages.h"
  19. #include "version.h"
  20. #include "ManagementPages.h" //formating functions...
  21. //////////////////////////////////////////////////////////////////////////////////////////
  22. //
  23. //
  24. //
  25. CRootWizard1::CRootWizard1(WIZ_POSITION pos, int nTitle)
  26. : CMySnapInPropertyWizardImpl<CRootWizard1> (pos, nTitle)
  27. {
  28. m_psp.dwFlags |= PSP_HASHELP;
  29. }
  30. LRESULT CRootWizard1::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  31. {
  32. HELPINFO *phi = (HELPINFO*) lParam;
  33. if (phi && phi->iContextType == HELPINFO_WINDOW)
  34. {
  35. IDCsToIDHs HelpMap[] = {
  36. {0,0} };
  37. ::WinHelp((HWND) phi->hItemHandle, ContextHelpFile, HELP_WM_HELP, (DWORD_PTR) &HelpMap);
  38. return TRUE;
  39. }
  40. bHandled = FALSE;
  41. return FALSE;
  42. }
  43. BOOL CRootWizard1::OnHelp()
  44. {
  45. MMCPropertyHelp(const_cast<TCHAR*>(HELP_overview));
  46. return TRUE;
  47. }
  48. //////////////////////////////////////////////////////////////////////////////////////////
  49. //
  50. //
  51. //
  52. CRootWizard2::CRootWizard2(WIZ_POSITION pos, int nTitle, CBaseNode* pNode)
  53. : CMySnapInPropertyWizardImpl<CRootWizard2> (pos, nTitle), m_pNode(pNode)
  54. {
  55. bLocal = TRUE;
  56. memset(&Computer, 0, sizeof(Computer));
  57. //m_psp.dwFlags |= PSP_HASHELP;
  58. }
  59. CRootWizard2::~CRootWizard2()
  60. {
  61. }
  62. LRESULT CRootWizard2::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  63. {
  64. UpdateData(FALSE);
  65. return 1;
  66. }
  67. LRESULT CRootWizard2::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  68. {
  69. HELPINFO *phi = (HELPINFO*) lParam;
  70. if (phi && phi->iContextType == HELPINFO_WINDOW)
  71. {
  72. IDCsToIDHs HelpMap[] = {{IDC_SNAPIN_MANAGE_FRAME, HELP_wizCONNECT_FRAME},
  73. {IDC_LOCAL_RD, HELP_wizCONNECT_LOCAL},
  74. {IDC_ANOTHER_RD, HELP_wizCONNECT_ANOTHER},
  75. {IDC_COMPUTER, HELP_wizCONNECT_COMPUTER},
  76. {IDC_BROWSE, HELP_wizCONNECT_BROWSE},
  77. {0,0} };
  78. ::WinHelp((HWND) phi->hItemHandle, ContextHelpFile, HELP_WM_HELP, (DWORD_PTR) &HelpMap);
  79. return TRUE;
  80. }
  81. bHandled = FALSE;
  82. return FALSE;
  83. }
  84. BOOL CRootWizard2::OnHelp()
  85. {
  86. //MMCPropertyHelp(const_cast<TCHAR*>(HELP_howto_changecomputer));
  87. return TRUE;
  88. }
  89. BOOL CRootWizard2::UpdateData(BOOL bSaveAndValidate)
  90. {
  91. if (bSaveAndValidate)
  92. {
  93. BOOL bLocalChk = IsDlgButtonChecked(IDC_LOCAL_RD);
  94. ASSERT(bLocalChk != (BOOL) IsDlgButtonChecked(IDC_ANOTHER_RD));
  95. CComBSTR bStr;
  96. if (!GetDlgItemText(IDC_COMPUTER, bStr.m_str))
  97. bStr = _T("");
  98. TCHAR *start = bStr;
  99. while (*start && *start == '\\') start++;
  100. UINT len = _tcslen(start);
  101. if (!bLocalChk && ( len < 1 || len > SNAPIN_MAX_COMPUTERNAME_LENGTH) )
  102. {
  103. HWND hWndCtl = GetDlgItem(IDC_COMPUTER);
  104. if(hWndCtl)
  105. VERIFY(::SetFocus(hWndCtl)); // $$ why doesn't this work? works in other cases...
  106. return FALSE;
  107. }
  108. bLocal = bLocalChk;
  109. _tcscpy(&Computer[0], start);
  110. return TRUE;
  111. }
  112. else
  113. {
  114. VERIFY( SetDlgItemText(IDC_COMPUTER, _T("")) );
  115. VERIFY( CheckRadioButton(IDC_LOCAL_RD, IDC_ANOTHER_RD, bLocal ? IDC_LOCAL_RD : IDC_ANOTHER_RD) );
  116. HWND hWndCtl = GetDlgItem(IDC_COMPUTER);
  117. ASSERT(hWndCtl);
  118. if (hWndCtl)
  119. ::EnableWindow(hWndCtl, !bLocal);
  120. hWndCtl = GetDlgItem(IDC_BROWSE);
  121. ASSERT(hWndCtl);
  122. if (hWndCtl)
  123. ::EnableWindow(hWndCtl, !bLocal);
  124. return TRUE;
  125. }
  126. }
  127. LRESULT CRootWizard2::OnConnectType(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  128. {
  129. if (wNotifyCode == BN_CLICKED)
  130. {
  131. BOOL Remote = FALSE;
  132. switch (wID) {
  133. case IDC_ANOTHER_RD:
  134. Remote = TRUE;
  135. break;
  136. case IDC_LOCAL_RD:
  137. default:
  138. break;
  139. }
  140. HWND hWndCtl = GetDlgItem(IDC_COMPUTER);
  141. ASSERT(hWndCtl);
  142. if (hWndCtl)
  143. ::EnableWindow(hWndCtl, Remote);
  144. hWndCtl = GetDlgItem(IDC_BROWSE);
  145. ASSERT(hWndCtl);
  146. if (hWndCtl)
  147. ::EnableWindow(hWndCtl, Remote);
  148. }
  149. bHandled = FALSE;
  150. return 0;
  151. }
  152. BOOL CRootWizard2::OnWizardFinish()
  153. {
  154. if (UpdateData(TRUE))
  155. {
  156. CRootFolder *Root = dynamic_cast<CRootFolder *>(m_pNode);
  157. if (Root)
  158. Root->Config(bLocal, Computer);
  159. return TRUE;
  160. }
  161. MessageBeep(MB_ICONASTERISK);
  162. return FALSE;
  163. }
  164. LRESULT CRootWizard2::OnBrowse(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  165. {
  166. if (wNotifyCode != BN_CLICKED || wID != IDC_BROWSE)
  167. {
  168. bHandled = FALSE;
  169. return 1;
  170. }
  171. ITEM_STR title;
  172. LoadStringHelper(title, IDS_COMPUTER_PROMPT);
  173. LPMALLOC pMalloc;
  174. LPITEMIDLIST pidl;
  175. BROWSEINFO info = { 0 };
  176. if (SUCCEEDED(SHGetMalloc(&pMalloc)))
  177. {
  178. LPITEMIDLIST pidl_start = NULL;
  179. HRESULT res = SHGetSpecialFolderLocation( NULL, CSIDL_NETWORK, &pidl_start);
  180. TCHAR *lpBuffer = (TCHAR *) (pMalloc->Alloc( MAX_PATH * sizeof(TCHAR) ));
  181. if (lpBuffer)
  182. {
  183. info.hwndOwner = GetParent();
  184. info.pidlRoot = (res == NOERROR) ? pidl_start : NULL;
  185. info.pszDisplayName = lpBuffer;
  186. info.lpszTitle = title;
  187. info.ulFlags = BIF_BROWSEFORCOMPUTER;
  188. // info.lpfn = NULL;
  189. // info.lParam = 0;
  190. // info.iImage
  191. memset(lpBuffer, 0, MAX_PATH * sizeof(TCHAR) );
  192. pidl = SHBrowseForFolder(&info);
  193. if (pidl)
  194. {
  195. VERIFY(SetDlgItemText(IDC_COMPUTER, lpBuffer));
  196. pMalloc->Free(pidl);
  197. }
  198. pMalloc->Free(lpBuffer);
  199. }
  200. if (res == NOERROR)
  201. pMalloc->Free(pidl_start);
  202. pMalloc->Release();
  203. }
  204. return 0;
  205. }
  206. //////////////////////////////////////////////////////////////////////////////////////////
  207. //
  208. //
  209. //
  210. CRootGeneralPage::CRootGeneralPage(int nTitle)
  211. : CMySnapInPropertyPageImpl<CRootGeneralPage> (nTitle)
  212. {
  213. m_psp.dwFlags |= PSP_HASHELP;
  214. }
  215. CRootGeneralPage::~CRootGeneralPage()
  216. {
  217. }
  218. LRESULT CRootGeneralPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  219. {
  220. bHandled = FALSE;
  221. return TRUE;
  222. }
  223. LRESULT CRootGeneralPage::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  224. {
  225. HELPINFO *phi = (HELPINFO*) lParam;
  226. if (phi && phi->iContextType == HELPINFO_WINDOW)
  227. {
  228. IDCsToIDHs HelpMap[] = {
  229. {0,0} };
  230. ::WinHelp((HWND) phi->hItemHandle, ContextHelpFile, HELP_WM_HELP, (DWORD_PTR) &HelpMap);
  231. return TRUE;
  232. }
  233. bHandled = FALSE;
  234. return FALSE;
  235. }
  236. BOOL CRootGeneralPage::OnHelp()
  237. {
  238. MMCPropertyHelp(const_cast<TCHAR*>(HELP_overview));
  239. return TRUE;
  240. }
  241. BOOL CRootGeneralPage::OnSetActive()
  242. {
  243. CComBSTR bName;
  244. VERIFY(bName.LoadString(IDS_PROCESS_CONTROL));
  245. if (bName.Length())
  246. PropSheet_SetTitle( GetParent(), PSH_PROPTITLE, bName.m_str);
  247. return TRUE;
  248. }
  249. //////////////////////////////////////////////////////////////////////////////////////////
  250. //
  251. //
  252. //
  253. CRootVersionPage::CRootVersionPage(int nTitle)
  254. : CMySnapInPropertyPageImpl<CRootVersionPage>(nTitle), VersionObj(_Module.GetModuleInstance())
  255. {
  256. // m_psp.dwFlags |= PSP_HASHELP;
  257. }
  258. LRESULT CRootVersionPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  259. {
  260. SetDlgItemText(IDC_FILEVERSION, VersionObj.GetFileVersion() );
  261. SetDlgItemText(IDC_DESCRIPTION, VersionObj.strGetFileDescription() );
  262. SetDlgItemText(IDC_COPYRIGHT, VersionObj.strGetLegalCopyright() );
  263. struct {
  264. int id;
  265. const TCHAR *str;
  266. } idmap[] = { {IDS_COMPANYNAME, VersionObj.strGetCompanyName() }, {IDS_FILEDESCRIPTION, VersionObj.strGetFileDescription() },
  267. {IDS_FILEVERSION, VersionObj.strGetFileVersion() }, {IDS_INTERNALNAME, VersionObj.strGetInternalName() },
  268. {IDS_LEGALCOPYRIGHT, VersionObj.strGetLegalCopyright()}, {IDS_ORIGINALFILENAME, VersionObj.strGetOriginalFilename() },
  269. {IDS_PRODUCTNAME, VersionObj.strGetProductName() }, {IDS_PRODUCTVERSION, VersionObj.strGetProductVersion() },
  270. {IDS_COMMENTS, VersionObj.strGetComments() }, {IDS_LEGALTRADEMARKS, VersionObj.strGetLegalTrademarks() },
  271. {IDS_PRIVATEBUILD, VersionObj.strGetPrivateBuild() }, {IDS_SPECIALBUILD, VersionObj.strGetSpecialBuild() },
  272. };
  273. LRESULT index;
  274. ITEM_STR str;
  275. for (int i=0; i < ARRAY_SIZE(idmap); i++)
  276. {
  277. index = SendDlgItemMessage( IDC_ITEMS, LB_ADDSTRING, 0, (LPARAM) LoadStringHelper(str, idmap[i].id) );
  278. if (index >= 0)
  279. SendDlgItemMessage(IDC_ITEMS, LB_SETITEMDATA, index, (LPARAM) idmap[i].str);
  280. }
  281. index = SendDlgItemMessage( IDC_ITEMS, LB_FINDSTRINGEXACT, -1, (LPARAM) LoadStringHelper(str, IDS_COMPANYNAME));
  282. SendDlgItemMessage( IDC_ITEMS, LB_SETCURSEL, index, 0);
  283. SetDlgItemText(IDC_VALUE, VersionObj.strGetCompanyName() );
  284. return 1;
  285. }
  286. LRESULT CRootVersionPage::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  287. {
  288. HELPINFO *phi = (HELPINFO*) lParam;
  289. if (phi && phi->iContextType == HELPINFO_WINDOW)
  290. {
  291. IDCsToIDHs HelpMap[] = {{IDC_FILEVERSION, HELP_VER_FILE},
  292. {IDC_DESCRIPTION, HELP_VER_DESCRIPTION},
  293. {IDC_COPYRIGHT, HELP_VER_COPYRIGHT},
  294. {IDC_VERSION_FRAME, HELP_VER_OTHER_FRAME},
  295. {IDC_ITEMS, HELP_VER_ITEM},
  296. {IDC_VALUE, HELP_VER_VALUE},
  297. {0,0} };
  298. ::WinHelp((HWND) phi->hItemHandle, ContextHelpFile, HELP_WM_HELP, (DWORD_PTR) &HelpMap);
  299. return TRUE;
  300. }
  301. bHandled = FALSE;
  302. return FALSE;
  303. }
  304. BOOL CRootVersionPage::OnHelp()
  305. {
  306. //MMCPropertyHelp(const_cast<TCHAR*>(HELP_overview));
  307. return TRUE;
  308. }
  309. LRESULT CRootVersionPage::OnItemsSelection(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  310. {
  311. if (wID != IDC_ITEMS || wNotifyCode != LBN_SELCHANGE)
  312. {
  313. bHandled = FALSE;
  314. return 1;
  315. }
  316. LRESULT index = SendDlgItemMessage( IDC_ITEMS, LB_GETCURSEL, 0, 0);
  317. if ( LB_ERR != index )
  318. {
  319. LRESULT lResult = SendDlgItemMessage(IDC_ITEMS, LB_GETITEMDATA, index, 0);
  320. if (LB_ERR != lResult)
  321. SetDlgItemText(IDC_VALUE, (TCHAR *) lResult);
  322. }
  323. return 1;
  324. }
  325. BOOL CRootVersionPage::OnSetActive()
  326. {
  327. CComBSTR bName;
  328. VERIFY(bName.LoadString(IDS_PROCESS_CONTROL));
  329. if (bName.Length())
  330. PropSheet_SetTitle( GetParent(), PSH_PROPTITLE, bName.m_str);
  331. return TRUE;
  332. }
  333. //////////////////////////////////////////////////////////////////////////////////////////
  334. //
  335. //
  336. //
  337. CRootServicePage::CRootServicePage(int nTitle, CServicePageContainer *pContainer) : CMySnapInPropertyPageImpl<CRootServicePage> (nTitle), m_pContainer(pContainer)
  338. {
  339. PageFields.on = 0;
  340. m_bReadOnly = FALSE;
  341. memset(&PCInfo, 0, sizeof(PCInfo));
  342. //m_psp.dwFlags |= PSP_HASHELP;
  343. m_pContainer->AddRef();
  344. }
  345. CRootServicePage::~CRootServicePage()
  346. {
  347. m_pContainer->Release();
  348. }
  349. LRESULT CRootServicePage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  350. {
  351. UpdateData(FALSE);
  352. return 1;
  353. }
  354. LRESULT CRootServicePage::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  355. {
  356. HELPINFO *phi = (HELPINFO*) lParam;
  357. if (phi && phi->iContextType == HELPINFO_WINDOW)
  358. {
  359. IDCsToIDHs HelpMap[] = {
  360. {IDC_FILEVERSION, HELP_SERVICE_FILEVER},
  361. {IDC_PRODUCTVERSION, HELP_SERVICE_PRODUCTVER},
  362. {IDC_MGMT_FRAME, HELP_SERVICE_MGMT_FRAME},
  363. {IDC_INTERVAL, HELP_SERVICE_SCANINTERVAL},
  364. {IDC_SPIN, HELP_SERVICE_SCANINTERVAL_SP},
  365. {IDC_COMMTIMEOUT, HELP_SERVICE_REQSTTIMEOUT},
  366. {IDC_COMMTIMEOUT_SPIN, HELP_SERVICE_REQSTTIMEOUT_SP},
  367. {IDC_TARGET_FRAME, HELP_SERVICE_TARGET_FRAME},
  368. {IDC_ITEMS, HELP_SERVICE_ITEM},
  369. {IDC_VALUE, HELP_SERVICE_VALUE},
  370. {0,0} };
  371. ::WinHelp((HWND) phi->hItemHandle, ContextHelpFile, HELP_WM_HELP, (DWORD_PTR) &HelpMap);
  372. return TRUE;
  373. }
  374. bHandled = FALSE;
  375. return FALSE;
  376. }
  377. BOOL CRootServicePage::OnHelp()
  378. {
  379. //MMCPropertyHelp(const_cast<TCHAR*>(HELP_serv_overview));
  380. return TRUE;
  381. }
  382. BOOL CRootServicePage::OnSetActive()
  383. {
  384. CComBSTR bName;
  385. VERIFY(bName.LoadString(IDS_PROCESS_CONTROL));
  386. if (!bName.Length())
  387. bName = _T("");
  388. CComBSTR bTitle;
  389. PropSheet_SetTitle( GetParent(), PSH_PROPTITLE,
  390. FormatSheetTitle(bTitle, bName, m_pContainer->GetConnectionInfo()) );
  391. return TRUE;
  392. }
  393. BOOL CRootServicePage::UpdateData(BOOL bSaveAndValidate)
  394. {
  395. if (bSaveAndValidate)
  396. {
  397. return Validate(TRUE);
  398. }
  399. else
  400. {
  401. SetDlgItemText(IDC_FILEVERSION, PCInfo.fileVersion );
  402. SetDlgItemText(IDC_PRODUCTVERSION, PCInfo.productVersion );
  403. int str_ids[] = { IDS_NUM_PROCESSORS, IDS_MEMORY_PAGESIZE, IDS_MEDIATOR_FILEVERSION, IDS_MEDIATOR_PRODUCTVERSION };
  404. LRESULT index;
  405. ITEM_STR str;
  406. for (int i=0; i < ARRAY_SIZE(str_ids); i++)
  407. {
  408. index = SendDlgItemMessage( IDC_ITEMS, LB_ADDSTRING, 0, (LPARAM) LoadStringHelper(str, str_ids[i]) );
  409. if (index >= 0)
  410. SendDlgItemMessage(IDC_ITEMS, LB_SETITEMDATA, index, (LPARAM) str_ids[i]);
  411. }
  412. index = SendDlgItemMessage( IDC_ITEMS, LB_FINDSTRINGEXACT, -1, (LPARAM) LoadStringHelper(str, IDS_NUM_PROCESSORS));
  413. SendDlgItemMessage( IDC_ITEMS, LB_SETCURSEL, index, 0);
  414. SetDlgItemText(IDC_VALUE, FormatPCINT32(str, PCInfo.sysParms.numberOfProcessors));
  415. SendDlgItemMessage(IDC_SPIN, UDM_SETRANGE32, PC_MIN_POLL_DELAY, PC_MAX_POLL_DELAY);
  416. if (PCInfo.sysParms.manageIntervalSeconds)
  417. SendDlgItemMessage(IDC_SPIN, UDM_SETPOS32, 0, PCInfo.sysParms.manageIntervalSeconds );
  418. SendDlgItemMessage(IDC_COMMTIMEOUT_SPIN, UDM_SETRANGE32, PC_MIN_TIMEOUT, PC_MAX_TIMEOUT);
  419. SendDlgItemMessage(IDC_COMMTIMEOUT_SPIN, UDM_SETPOS32, 0, PCInfo.sysParms.timeoutValueMs );
  420. if ( m_bReadOnly )
  421. {
  422. DisableControl(IDC_SPIN);
  423. DisableControl(IDC_INTERVAL);
  424. DisableControl(IDC_COMMTIMEOUT_SPIN);
  425. DisableControl(IDC_COMMTIMEOUT);
  426. }
  427. return TRUE;
  428. }
  429. }
  430. BOOL CRootServicePage::Validate(BOOL bSave)
  431. {
  432. LONG_PTR Err = 0;
  433. LRESULT manageIntervalSeconds = SendDlgItemMessage(IDC_SPIN, UDM_GETPOS32, 0, (LPARAM) &Err);
  434. if (Err || manageIntervalSeconds < PC_MIN_POLL_DELAY || manageIntervalSeconds > PC_MAX_POLL_DELAY)
  435. {
  436. MessageBeep(MB_ICONASTERISK);
  437. HWND hWndCtl = GetDlgItem(IDC_SPIN);
  438. if(hWndCtl)
  439. ::SetFocus(hWndCtl);
  440. return FALSE;
  441. }
  442. LRESULT timeoutValueMs = SendDlgItemMessage(IDC_COMMTIMEOUT_SPIN, UDM_GETPOS32, 0, (LPARAM) &Err);
  443. if (Err || timeoutValueMs < PC_MIN_TIMEOUT || timeoutValueMs > PC_MAX_TIMEOUT)
  444. {
  445. MessageBeep(MB_ICONASTERISK);
  446. HWND hWndCtl = GetDlgItem(IDC_COMMTIMEOUT_SPIN);
  447. if(hWndCtl)
  448. ::SetFocus(hWndCtl);
  449. return FALSE;
  450. }
  451. if (bSave)
  452. {
  453. m_pContainer->m_new.manageIntervalSeconds = (PCINT32) manageIntervalSeconds;
  454. m_pContainer->m_new.timeoutValueMs = (PCINT32) timeoutValueMs;
  455. }
  456. return TRUE;
  457. }
  458. LRESULT CRootServicePage::OnEditChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  459. {
  460. LONG_PTR Err = 0;
  461. if (wID == IDC_INTERVAL)
  462. {
  463. LRESULT manageIntervalSeconds = SendDlgItemMessage(IDC_SPIN, UDM_GETPOS32, 0, (LPARAM) &Err);
  464. PageFields.Fields.manageinterval = FALSE;
  465. if (!Err && manageIntervalSeconds >= PC_MIN_POLL_DELAY && manageIntervalSeconds <= PC_MAX_POLL_DELAY)
  466. PageFields.Fields.manageinterval = (PCInfo.sysParms.manageIntervalSeconds != (PCINT32) manageIntervalSeconds);
  467. }
  468. if (wID == IDC_COMMTIMEOUT)
  469. {
  470. LRESULT timeoutValueMs = SendDlgItemMessage(IDC_COMMTIMEOUT_SPIN, UDM_GETPOS32, 0, (LPARAM) &Err);
  471. PageFields.Fields.timeoutValueMs = FALSE;
  472. if (!Err && timeoutValueMs >= PC_MIN_TIMEOUT && timeoutValueMs <= PC_MAX_TIMEOUT )
  473. PageFields.Fields.timeoutValueMs = (PCInfo.sysParms.timeoutValueMs != (PCINT32) timeoutValueMs);
  474. }
  475. SetModified(PageFields.on);
  476. bHandled = FALSE;
  477. return 0;
  478. }
  479. LRESULT CRootServicePage::OnSpin(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  480. {
  481. if (idCtrl == IDC_COMMTIMEOUT_SPIN)
  482. {
  483. NMUPDOWN * nmupdown = (NMUPDOWN *) pnmh;
  484. if ((nmupdown->iPos + 100 * nmupdown->iDelta) >= PC_MIN_TIMEOUT &&
  485. (nmupdown->iPos + 100 * nmupdown->iDelta) <= PC_MAX_TIMEOUT )
  486. nmupdown->iDelta *= 100;
  487. }
  488. bHandled = FALSE;
  489. return 0;
  490. }
  491. LRESULT CRootServicePage::OnItemsSelection(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  492. {
  493. if (wID != IDC_ITEMS || wNotifyCode != LBN_SELCHANGE)
  494. {
  495. bHandled = FALSE;
  496. return 1;
  497. }
  498. LRESULT index = SendDlgItemMessage( IDC_ITEMS, LB_GETCURSEL, 0, 0);
  499. if (LB_ERR != index)
  500. {
  501. LRESULT lResult = SendDlgItemMessage(IDC_ITEMS, LB_GETITEMDATA, index, 0);
  502. if (LB_ERR != lResult)
  503. {
  504. ITEM_STR str = { 0 };
  505. switch (lResult)
  506. {
  507. case IDS_NUM_PROCESSORS:
  508. FormatPCINT32(str, PCInfo.sysParms.numberOfProcessors);
  509. SetDlgItemText(IDC_VALUE, str);
  510. break;
  511. case IDS_MEMORY_PAGESIZE:
  512. FormatPCINT32(str, PCInfo.sysParms.memoryPageSize);
  513. SetDlgItemText(IDC_VALUE, str);
  514. break;
  515. case IDS_MEDIATOR_FILEVERSION:
  516. SetDlgItemText(IDC_VALUE, PCInfo.medFileVersion);
  517. break;
  518. case IDS_MEDIATOR_PRODUCTVERSION:
  519. SetDlgItemText(IDC_VALUE, PCInfo.medProductVersion);
  520. break;
  521. default:
  522. ASSERT(FALSE);
  523. SetDlgItemText(IDC_VALUE, _T(""));
  524. break;
  525. }
  526. }
  527. }
  528. return 1;
  529. }
  530. BOOL CRootServicePage::OnApply()
  531. {
  532. if (m_bReadOnly || !PageFields.on)
  533. return TRUE;
  534. if ( m_pContainer->Apply(GetParent()) )
  535. {
  536. PageFields.on = 0;
  537. PCInfo.sysParms = m_pContainer->m_new;
  538. return TRUE;
  539. }
  540. return FALSE;
  541. }