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.

1995 lines
51 KiB

  1. /*======================================================================================//
  2. | Process Control //
  3. | //
  4. |Copyright (c) 1998 Sequent Computer Systems, Incorporated. All rights reserved. //
  5. | //
  6. |File Name: ManagementRuleWizards.cpp //
  7. | //
  8. |Description: Implementation of process management rule wizards //
  9. | //
  10. |Created: Paul Skoglund 09-1998 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #include "stdafx.h"
  16. #include "ManagementRuleWizards.h"
  17. #include "ManagementPages.h"
  18. using std::list<tstring>;
  19. bool GetGrpNameList(PCid id, list<tstring> &jobs)
  20. {
  21. PCINT32 res = 0;
  22. PCJobSummary jlist[min((COM_BUFFER_SIZE/sizeof(PCJobSummary)), 100)];
  23. memset(&jlist[0], 0, sizeof(PCJobSummary));
  24. do
  25. {
  26. res = PCGetJobSummary( id, jlist, ARRAY_SIZE(jlist) * sizeof(PCJobSummary));
  27. if (res < 0 )
  28. {
  29. PCULONG32 err = PCGetLastError(id);
  30. return false;
  31. }
  32. if (res > 0)
  33. {
  34. for (INT32 i = 0; i < res; i++)
  35. {
  36. jobs.push_back(jlist[i].jobName);
  37. }
  38. memcpy(&jlist[0], &jlist[res-1], sizeof(PCJobSummary));
  39. }
  40. } while (res > 0 && PCERROR_MORE_DATA == PCGetLastError(id) );
  41. return true;
  42. }
  43. list<tstring> *GetGrpNameList(PCid id)
  44. {
  45. list<tstring> *jlist = new list<tstring>;
  46. if (jlist)
  47. GetGrpNameList(id, *jlist);
  48. return jlist;
  49. }
  50. BOOL IsValidName(const CComBSTR &bStr, const BOOL nullOK)
  51. {
  52. ASSERT(PROC_NAME_LEN == JOB_NAME_LEN);
  53. const TCHAR BLANK = _T(' ');
  54. if ( !bStr.Length() ) // empty string
  55. return nullOK;
  56. unsigned int len = bStr.Length();
  57. if ( len > JOB_NAME_LEN )
  58. return FALSE;
  59. if ( bStr[0] == BLANK || bStr[len - 1] == BLANK )
  60. return FALSE; // leading/trailing blank
  61. if ( len != _tcscspn( bStr, _T("\\,\"")) )
  62. return FALSE; // hit invalid character
  63. return TRUE;
  64. }
  65. BOOL ProcRuleWizard(int nTitle, const list<tstring> &jobsdefined, PCProcDetail &out, const PCSystemParms &SystemParms, PROC_NAME *procName /* = NULL */)
  66. {
  67. PROPSHEETHEADER sheet;
  68. HPROPSHEETPAGE hPages[5];
  69. memset(&sheet, 0, sizeof(PROPSHEETHEADER));
  70. sheet.dwSize = sizeof(PROPSHEETHEADER);
  71. sheet.dwFlags = PSH_WIZARD; // | PSH_USEICONID;
  72. sheet.hwndParent = ::GetActiveWindow();
  73. sheet.hInstance = _Module.GetResourceInstance();
  74. sheet.pszIcon = NULL; // MAKEINTRESOURCE(IDI_MANAGEMENT);
  75. sheet.pszCaption = MAKEINTRESOURCE(nTitle);
  76. sheet.nPages = ARRAY_SIZE(hPages);
  77. sheet.nStartPage = 0;
  78. sheet.phpage = &hPages[0];
  79. sheet.pfnCallback = NULL;
  80. #if USE_WIZARD97_WATERMARKS
  81. sheet.dwFlags |= PSH_WIZARD97 | PSH_WATERMARK;
  82. sheet.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK1);
  83. #endif
  84. #if USE_WIZARD97_HEADERS
  85. sheet.dwFlags |= PSH_WIZARD97 | PSH_HEADER;
  86. sheet.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER1);
  87. #endif
  88. memset(&out, 0, sizeof(PCProcDetail));
  89. if (procName)
  90. _tcscpy(out.base.procName, *procName);
  91. // set any ProcDetail Defaults...
  92. //memset(out.base.memberOfJobName, 0, sizeof(JOB_NAME));
  93. //SetMGMTFlag(out.base.mgmtParms.mFlags, PCMFLAG_APPLY_JOB_MEMBERSHIP, FALSE);
  94. //out.base.mgmtParms.affinity = 0;
  95. //SetMGMTFlag(out.base.mgmtParms.mFlags, PCMFLAG_APPLY_AFFINITY, FALSE);
  96. out.base.mgmtParms.priority = PCPrioNormal;
  97. //SetMGMTFlag(out.base.mgmtParms.mFlags, PCMFLAG_APPLY_PRIORITY, FALSE);
  98. CProcNameWiz *pPage1 = new CProcNameWiz(CProcNameWiz::FIRST_PAGE, nTitle, &out);
  99. if (!pPage1)
  100. return -1;
  101. hPages[0] = pPage1->Create();
  102. if (procName)
  103. pPage1->SetNoNameChange();
  104. CProcGrpMemberWiz *pPage2 = new CProcGrpMemberWiz(CProcGrpMemberWiz::MIDDLE_PAGE, nTitle, &out, jobsdefined);
  105. if (!pPage2)
  106. {
  107. delete pPage1;
  108. return -1;
  109. }
  110. hPages[1] = pPage2->Create();
  111. CAffinityWiz *pPage3 = new CAffinityWiz(CAffinityWiz::MIDDLE_PAGE, nTitle, &out, SystemParms.processorMask);
  112. if (!pPage3)
  113. {
  114. delete pPage1;
  115. delete pPage2;
  116. return -1;
  117. }
  118. hPages[2] = pPage3->Create();
  119. CPriorityWiz *pPage4 = new CPriorityWiz(CPriorityWiz::MIDDLE_PAGE, nTitle, &out);
  120. if (!pPage4)
  121. {
  122. delete pPage1;
  123. delete pPage2;
  124. delete pPage3;
  125. return -1;
  126. }
  127. hPages[3] = pPage4->Create();
  128. CWorkingSetWiz *pPage5 = new CWorkingSetWiz(CWorkingSetWiz::LAST_PAGE, nTitle, &out);
  129. if (!pPage5)
  130. {
  131. delete pPage1;
  132. delete pPage2;
  133. delete pPage3;
  134. delete pPage4;
  135. return -1;
  136. }
  137. hPages[4] = pPage5->Create();
  138. INT_PTR id = PropertySheet(&sheet);
  139. if (id > 0)
  140. return TRUE;
  141. return FALSE;
  142. }
  143. BOOL GroupRuleWizard(int nTitle, PCJobDetail &out, const PCSystemParms &SystemParms, JOB_NAME *jobName /* = NULL */)
  144. {
  145. PROPSHEETHEADER sheet;
  146. HPROPSHEETPAGE hPages[10];
  147. memset(&sheet, 0, sizeof(PROPSHEETHEADER));
  148. sheet.dwSize = sizeof(PROPSHEETHEADER);
  149. sheet.dwFlags = PSH_WIZARD;
  150. sheet.hwndParent = ::GetActiveWindow();
  151. sheet.hInstance = _Module.GetResourceInstance();
  152. sheet.pszIcon = NULL;
  153. sheet.pszCaption = MAKEINTRESOURCE(nTitle);
  154. sheet.nPages = ARRAY_SIZE(hPages);
  155. sheet.nStartPage = 0;
  156. sheet.phpage = &hPages[0];
  157. sheet.pfnCallback = NULL;
  158. #if USE_WIZARD97_WATERMARKS
  159. sheet.dwFlags |= PSH_WIZARD97 | PSH_WATERMARK;
  160. sheet.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK1);
  161. #endif
  162. #if USE_WIZARD97_HEADERS
  163. sheet.dwFlags |= PSH_WIZARD97 | PSH_HEADER;
  164. sheet.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER1);
  165. #endif
  166. bool applyschedulingclass;
  167. SCHEDULING_CLASS schedulingclass;
  168. bool procmemorylimitchk;
  169. MEMORY_VALUE procmemorylimit;
  170. bool jobmemorylimitchk;
  171. MEMORY_VALUE jobmemorylimit;
  172. bool processcountchk;
  173. PROC_COUNT processcount;
  174. bool procusertimechk;
  175. TIME_VALUE procusertime;
  176. bool jobusertimechk;
  177. TIME_VALUE jobusertime;
  178. bool jobmsgontimelimit;
  179. bool breakaway;
  180. bool silentbreakaway;
  181. bool endjob;
  182. bool unhandledexcept;
  183. memset(&out, 0, sizeof(PCJobDetail));
  184. // set any JobDetail Defaults...
  185. if (jobName)
  186. _tcscpy(out.base.jobName, *jobName);
  187. //out.base.mgmtParms.affinity = 0;
  188. //SetMGMTFlag(out.base.mgmtParms.mFlags, PCMFLAG_APPLY_AFFINITY, FALSE);
  189. out.base.mgmtParms.priority = PCPrioNormal;
  190. //SetMGMTFlag(out.base.mgmtParms.mFlags, PCMFLAG_APPLY_PRIORITY, FALSE);
  191. CJobNameWiz *pPage1 = new CJobNameWiz(CJobNameWiz::FIRST_PAGE, nTitle, &out);
  192. if (!pPage1)
  193. return -1;
  194. hPages[0] = pPage1->Create();
  195. if (jobName)
  196. pPage1->SetNoNameChange();
  197. CAffinityWiz *pPage2 = new CAffinityWiz(CAffinityWiz::MIDDLE_PAGE, nTitle, &out, SystemParms.processorMask);
  198. if (!pPage2)
  199. {
  200. delete pPage1;
  201. return -1;
  202. }
  203. hPages[1] = pPage2->Create();
  204. CPriorityWiz *pPage3 = new CPriorityWiz(CPriorityWiz::MIDDLE_PAGE, nTitle, &out);
  205. if (!pPage3)
  206. {
  207. delete pPage1;
  208. delete pPage2;
  209. return -1;
  210. }
  211. hPages[2] = pPage3->Create();
  212. CSchedulingClassWiz *pPage4 = new CSchedulingClassWiz(CSchedulingClassWiz::MIDDLE_PAGE, nTitle, &schedulingclass, &applyschedulingclass);
  213. if (!pPage4)
  214. {
  215. delete pPage1;
  216. delete pPage2;
  217. delete pPage3;
  218. return -1;
  219. }
  220. hPages[3] = pPage4->Create();
  221. CWorkingSetWiz *pPage5 = new CWorkingSetWiz(CWorkingSetWiz::MIDDLE_PAGE, nTitle, &out);
  222. if (!pPage5)
  223. {
  224. delete pPage1;
  225. delete pPage2;
  226. delete pPage3;
  227. delete pPage4;
  228. return -1;
  229. }
  230. hPages[4] = pPage5->Create();
  231. CCommittedMemoryWiz *pPage6 = new CCommittedMemoryWiz(CCommittedMemoryWiz::MIDDLE_PAGE, nTitle, &procmemorylimit, &procmemorylimitchk, &jobmemorylimit, &jobmemorylimitchk);
  232. if (!pPage6)
  233. {
  234. delete pPage1;
  235. delete pPage2;
  236. delete pPage3;
  237. delete pPage4;
  238. delete pPage5;
  239. return -1;
  240. }
  241. hPages[5] = pPage6->Create();
  242. CProcCountWiz *pPage7 = new CProcCountWiz(CProcCountWiz::MIDDLE_PAGE, nTitle, &processcount, &processcountchk);
  243. if (!pPage7)
  244. {
  245. delete pPage1;
  246. delete pPage2;
  247. delete pPage3;
  248. delete pPage4;
  249. delete pPage5;
  250. delete pPage6;
  251. return -1;
  252. }
  253. hPages[6] = pPage7->Create();
  254. CTimeWiz *pPage8 = new CTimeWiz(CTimeWiz::MIDDLE_PAGE, nTitle, &procusertime, &procusertimechk, &jobusertime, &jobusertimechk, &jobmsgontimelimit);
  255. if (!pPage8)
  256. {
  257. delete pPage1;
  258. delete pPage2;
  259. delete pPage3;
  260. delete pPage4;
  261. delete pPage5;
  262. delete pPage6;
  263. delete pPage7;
  264. return -1;
  265. }
  266. hPages[7] = pPage8->Create();
  267. CAdvancedWiz *pPage9 = new CAdvancedWiz(CAdvancedWiz::MIDDLE_PAGE, nTitle, &endjob, &unhandledexcept);
  268. if (!pPage9)
  269. {
  270. delete pPage1;
  271. delete pPage2;
  272. delete pPage3;
  273. delete pPage4;
  274. delete pPage5;
  275. delete pPage6;
  276. delete pPage7;
  277. delete pPage8;
  278. return -1;
  279. }
  280. hPages[8] = pPage9->Create();
  281. CAdvBreakawayWiz *pPage10 = new CAdvBreakawayWiz(CAdvBreakawayWiz::LAST_PAGE, nTitle, &breakaway, &silentbreakaway);
  282. if (!pPage10)
  283. {
  284. delete pPage1;
  285. delete pPage2;
  286. delete pPage3;
  287. delete pPage4;
  288. delete pPage5;
  289. delete pPage6;
  290. delete pPage7;
  291. delete pPage8;
  292. delete pPage9;
  293. return -1;
  294. }
  295. hPages[9] = pPage10->Create();
  296. INT_PTR id = PropertySheet(&sheet);
  297. if (id > 0)
  298. {
  299. out.base.mgmtParms.schedClass = schedulingclass;
  300. if (applyschedulingclass)
  301. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_SCHEDULING_CLASS;
  302. out.base.mgmtParms.procMemoryLimit = procmemorylimit;
  303. if (procmemorylimitchk)
  304. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_PROC_MEMORY_LIMIT;
  305. out.base.mgmtParms.jobMemoryLimit = jobmemorylimit;
  306. if (jobmemorylimitchk)
  307. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_JOB_MEMORY_LIMIT;
  308. out.base.mgmtParms.procCountLimit = processcount;
  309. if (processcountchk)
  310. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_PROC_COUNT_LIMIT;
  311. out.base.mgmtParms.procTimeLimitCNS = procusertime;
  312. if (procusertimechk)
  313. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_PROC_TIME_LIMIT;
  314. out.base.mgmtParms.jobTimeLimitCNS = jobusertime;
  315. if (jobusertimechk)
  316. out.base.mgmtParms.mFlags |= PCMFLAG_APPLY_JOB_TIME_LIMIT;
  317. if (jobmsgontimelimit)
  318. out.base.mgmtParms.mFlags |= PCMFLAG_MSG_ON_JOB_TIME_LIMIT_HIT;
  319. if (endjob)
  320. out.base.mgmtParms.mFlags |= PCMFLAG_END_JOB_WHEN_EMPTY;
  321. if (unhandledexcept)
  322. out.base.mgmtParms.mFlags |= PCMFLAG_SET_DIE_ON_UH_EXCEPTION;
  323. if (breakaway)
  324. out.base.mgmtParms.mFlags |= PCMFLAG_SET_PROC_BREAKAWAY_OK;
  325. if (silentbreakaway)
  326. out.base.mgmtParms.mFlags |= PCMFLAG_SET_SILENT_BREAKAWAY;
  327. return TRUE;
  328. }
  329. return FALSE;
  330. }
  331. ///////////////////////////////////////////////////////////////////////////
  332. // ProcName
  333. CProcNameWiz::CProcNameWiz(WIZ_POSITION pos, int nTitle, PCProcDetail *ProcDetail) :
  334. CMySnapInPropertyWizardImpl<CProcNameWiz>(pos, nTitle), m_pProcDetail(ProcDetail)
  335. {
  336. ASSERT(m_pProcDetail);
  337. m_bReadOnly = FALSE;
  338. m_bNoNameChange = FALSE;
  339. }
  340. CProcNameWiz::~CProcNameWiz()
  341. {
  342. }
  343. LRESULT CProcNameWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  344. {
  345. UpdateData(FALSE);
  346. bHandled = FALSE;
  347. return TRUE; // Let the system set the focus
  348. }
  349. LRESULT CProcNameWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  350. {
  351. HELPINFO *phi = (HELPINFO*) lParam;
  352. if (phi && phi->iContextType == HELPINFO_WINDOW)
  353. {
  354. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_proc_name);
  355. MMCPropertyHelp(pTopic);
  356. return TRUE;
  357. }
  358. bHandled = FALSE;
  359. return FALSE;
  360. }
  361. BOOL CProcNameWiz::UpdateData(BOOL bSaveAndValidate)
  362. {
  363. if (bSaveAndValidate)
  364. {
  365. CComBSTR bName;
  366. if (!GetDlgItemText( IDC_NAME, bName.m_str ) ||
  367. !IsValidName(bName, FALSE) )
  368. {
  369. HWND hWndCtl = GetDlgItem(IDC_NAME);
  370. if(hWndCtl)
  371. ::SetFocus(hWndCtl);
  372. ITEM_STR strOut;
  373. LoadStringHelper(strOut, IDS_JOBNAME_WARNING);
  374. MessageBox(strOut, NULL, MB_OK | MB_ICONWARNING);
  375. return FALSE;
  376. }
  377. CComBSTR bComment;
  378. if ( !GetDlgItemText(IDC_COMMENT, bComment.m_str) )
  379. bComment = _T("");
  380. if (bComment.Length() > RULE_DESCRIPTION_LEN)
  381. {
  382. HWND hWndCtl = GetDlgItem(IDC_COMMENT);
  383. if(hWndCtl)
  384. ::SetFocus(hWndCtl);
  385. MessageBeep(MB_ICONASTERISK);
  386. return FALSE;
  387. }
  388. // everything validated so save
  389. _tcscpy(m_pProcDetail->base.procName, bName);
  390. _tcscpy(m_pProcDetail->base.mgmtParms.description, bComment);
  391. return TRUE;
  392. }
  393. else
  394. {
  395. VERIFY(SetDlgItemText( IDC_NAME, m_pProcDetail->base.procName ));
  396. SendDlgItemMessage( IDC_NAME, EM_SETLIMITTEXT, PROC_NAME_LEN, 0);
  397. VERIFY(SetDlgItemText( IDC_COMMENT, m_pProcDetail->base.mgmtParms.description ));
  398. SendDlgItemMessage( IDC_COMMENT, EM_SETLIMITTEXT, RULE_DESCRIPTION_LEN, 0);
  399. if (m_bReadOnly)
  400. {
  401. DisableControl(IDC_NAME);
  402. DisableControl(IDC_COMMENT);
  403. }
  404. if (m_bNoNameChange)
  405. DisableControl(IDC_NAME);
  406. return TRUE;
  407. }
  408. }
  409. BOOL CProcNameWiz::OnWizardNext()
  410. {
  411. if (!UpdateData(TRUE) )
  412. return FALSE;
  413. return TRUE;
  414. }
  415. ///////////////////////////////////////////////////////////////////////////
  416. // JobMember
  417. CProcGrpMemberWiz::CProcGrpMemberWiz(WIZ_POSITION pos, int nTitle, PCProcDetail *ProcDetail, const list<tstring> &jobsdefined)
  418. : CMySnapInPropertyWizardImpl<CProcGrpMemberWiz>(pos, nTitle),
  419. m_pProcDetail(ProcDetail), m_JobsExisting(jobsdefined)
  420. {
  421. ASSERT(ProcDetail);
  422. m_bReadOnly = FALSE;
  423. }
  424. CProcGrpMemberWiz::~CProcGrpMemberWiz()
  425. {
  426. }
  427. LRESULT CProcGrpMemberWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  428. {
  429. UpdateData(FALSE);
  430. bHandled = FALSE;
  431. return TRUE; // Let the system set the focus
  432. }
  433. LRESULT CProcGrpMemberWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  434. {
  435. HELPINFO *phi = (HELPINFO*) lParam;
  436. if (phi && phi->iContextType == HELPINFO_WINDOW)
  437. {
  438. TCHAR *pTopic = const_cast<TCHAR*>(HELP_pr_job_name);
  439. MMCPropertyHelp(pTopic);
  440. return TRUE;
  441. }
  442. bHandled = FALSE;
  443. return FALSE;
  444. }
  445. BOOL CProcGrpMemberWiz::UpdateData(BOOL bSaveAndValidate)
  446. {
  447. if (bSaveAndValidate)
  448. {
  449. CComBSTR bStr;
  450. bool bChecked = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBMEMBER_CHK));
  451. if (!GetDlgItemText( IDC_JOB_LIST, bStr.m_str ) )
  452. bStr = _T("");
  453. if ( !IsValidName(bStr, !bChecked) )
  454. {
  455. HWND hWndCtl = NULL;
  456. if (bChecked)
  457. hWndCtl = GetDlgItem(IDC_JOB_LIST);
  458. else
  459. hWndCtl = GetDlgItem(IDC_JOBMEMBER_CHK);
  460. if(hWndCtl)
  461. ::SetFocus(hWndCtl);
  462. ITEM_STR strOut;
  463. LoadStringHelper(strOut, IDS_JOBNAME_WARNING);
  464. MessageBox(strOut, NULL, MB_OK | MB_ICONWARNING);
  465. return FALSE;
  466. }
  467. SetMGMTFlag(m_pProcDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_JOB_MEMBERSHIP, bChecked);
  468. _tcscpy(m_pProcDetail->base.memberOfJobName, bStr);
  469. return TRUE;
  470. }
  471. else
  472. {
  473. list<tstring>::const_iterator i;
  474. for (i = m_JobsExisting.begin(); i != m_JobsExisting.end(); i++)
  475. SendDlgItemMessage(IDC_JOB_LIST, CB_ADDSTRING, 0, (LPARAM) (*i).c_str() );
  476. SendDlgItemMessage( IDC_JOB_LIST, CB_LIMITTEXT, JOB_NAME_LEN, 0);
  477. VERIFY(SetDlgItemText( IDC_JOB_LIST, m_pProcDetail->base.memberOfJobName ));
  478. CheckDlgButton(IDC_JOBMEMBER_CHK, (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_JOB_MEMBERSHIP) ? BST_CHECKED : BST_UNCHECKED);
  479. if (m_bReadOnly || !(m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_JOB_MEMBERSHIP) )
  480. DisableControl(IDC_JOB_LIST);
  481. if (m_bReadOnly)
  482. DisableControl(IDC_JOBMEMBER_CHK);
  483. return TRUE;
  484. }
  485. }
  486. LRESULT CProcGrpMemberWiz::OnJobChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  487. {
  488. if (wID == IDC_JOBMEMBER_CHK )
  489. {
  490. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBMEMBER_CHK));
  491. ::EnableWindow(GetDlgItem(IDC_JOB_LIST), checked);
  492. }
  493. bHandled = FALSE;
  494. return 0;
  495. }
  496. BOOL CProcGrpMemberWiz::OnWizardNext()
  497. {
  498. if (!UpdateData(TRUE) )
  499. return FALSE;
  500. return TRUE;
  501. }
  502. ///////////////////////////////////////////////////////////////////////////
  503. // Affinity
  504. CAffinityWiz::CAffinityWiz(WIZ_POSITION pos, int nTitle, PCProcDetail *ProcDetail, AFFINITY ProcessorMask) :
  505. CMySnapInPropertyWizardImpl<CAffinityWiz>(pos, nTitle),
  506. m_PageType(PROCESS_PAGE), m_pProcDetail(ProcDetail), m_pJobDetail(NULL),
  507. m_ProcessorMask(ProcessorMask)
  508. {
  509. Initialize();
  510. }
  511. CAffinityWiz::CAffinityWiz(WIZ_POSITION pos, int nTitle, PCJobDetail *JobDetail, AFFINITY ProcessorMask) :
  512. CMySnapInPropertyWizardImpl<CAffinityWiz>(pos, nTitle),
  513. m_PageType(JOB_PAGE), m_pProcDetail(NULL), m_pJobDetail(JobDetail),
  514. m_ProcessorMask(ProcessorMask)
  515. {
  516. Initialize();
  517. }
  518. CAffinityWiz::~CAffinityWiz()
  519. {
  520. }
  521. void CAffinityWiz::Initialize()
  522. {
  523. ASSERT(m_PageType == PROCESS_PAGE && m_pProcDetail || m_PageType == JOB_PAGE && m_pJobDetail);
  524. m_bReadOnly = FALSE;
  525. }
  526. LRESULT CAffinityWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  527. {
  528. UINT nPromptID;
  529. if (m_PageType == PROCESS_PAGE)
  530. nPromptID = IDS_AFFINITY_JOBWARNING;
  531. else
  532. nPromptID = IDS_AFFINITY_NOJOBWARNING;
  533. CComBSTR bStr;
  534. if (bStr.LoadString(nPromptID))
  535. VERIFY(SetDlgItemText(IDC_AFFINITY_PROMPT, bStr.m_str));
  536. UpdateData(FALSE);
  537. bHandled = FALSE;
  538. return TRUE; // Let the system set the focus
  539. }
  540. LRESULT CAffinityWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  541. {
  542. HELPINFO *phi = (HELPINFO*) lParam;
  543. if (phi && phi->iContextType == HELPINFO_WINDOW)
  544. {
  545. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_affinity);
  546. MMCPropertyHelp(pTopic);
  547. return TRUE;
  548. }
  549. bHandled = FALSE;
  550. return FALSE;
  551. }
  552. BOOL CAffinityWiz::UpdateData(BOOL bSaveAndValidate)
  553. {
  554. if (bSaveAndValidate)
  555. {
  556. AFFINITY affinity = 0;
  557. bool affinitychk = (BST_CHECKED == IsDlgButtonChecked(IDC_AFFINITY_CHK));
  558. int i;
  559. for ( i = IDC_AFFINITY1; i <= IDC_AFFINITY64; i++)
  560. {
  561. if ( BST_UNCHECKED != IsDlgButtonChecked(i) )
  562. affinity |= (ProcessorBit << (i - IDC_AFFINITY1));
  563. }
  564. // Warn the user if the affinity and processor mask don't
  565. // reference at least one processor
  566. if (affinitychk && !(affinity & m_ProcessorMask) )
  567. {
  568. ITEM_STR strOut;
  569. LoadStringHelper(strOut, IDS_AFFINITY_WARNING);
  570. if (IDYES != MessageBox(strOut, NULL, MB_YESNO | MB_ICONQUESTION))
  571. return FALSE;
  572. }
  573. if (m_PageType == PROCESS_PAGE)
  574. {
  575. m_pProcDetail->base.mgmtParms.affinity = affinity;
  576. SetMGMTFlag(m_pProcDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_AFFINITY, affinitychk);
  577. }
  578. else if (m_PageType == JOB_PAGE)
  579. {
  580. m_pJobDetail->base.mgmtParms.affinity = affinity;
  581. SetMGMTFlag(m_pJobDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_AFFINITY, affinitychk);
  582. }
  583. return TRUE;
  584. }
  585. else
  586. {
  587. ASSERT(IDC_AFFINITY1 + 63 == IDC_AFFINITY64);
  588. AFFINITY affinity = 0;
  589. bool affinitychk = FALSE;
  590. if ( m_PageType == PROCESS_PAGE )
  591. {
  592. affinity = m_pProcDetail->base.mgmtParms.affinity;
  593. if (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_AFFINITY)
  594. affinitychk = TRUE;
  595. }
  596. else if ( m_PageType == JOB_PAGE )
  597. {
  598. affinity = m_pJobDetail->base.mgmtParms.affinity;
  599. if (m_pJobDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_AFFINITY)
  600. affinitychk = TRUE;
  601. }
  602. for(int i = IDC_AFFINITY1; i <= IDC_AFFINITY64; i++)
  603. {
  604. if (affinity & (ProcessorBit << (i - IDC_AFFINITY1) ) )
  605. {
  606. if (m_ProcessorMask & (ProcessorBit << (i - IDC_AFFINITY1)))
  607. CheckDlgButton(i, BST_CHECKED);
  608. else
  609. CheckDlgButton(i, BST_INDETERMINATE);
  610. }
  611. else
  612. CheckDlgButton(i, BST_UNCHECKED);
  613. }
  614. CheckDlgButton(IDC_AFFINITY_CHK, affinitychk ? BST_CHECKED : BST_UNCHECKED);
  615. ApplyControlEnableRules(FALSE);
  616. return TRUE;
  617. }
  618. }
  619. void CAffinityWiz::ApplyControlEnableRules(BOOL bForceDisable)
  620. {
  621. BOOL bEnable;
  622. if (m_bReadOnly || !(BST_CHECKED == IsDlgButtonChecked(IDC_AFFINITY_CHK)) || bForceDisable)
  623. bEnable = FALSE;
  624. else
  625. bEnable = TRUE;
  626. for (int i = IDC_AFFINITY1; i <= IDC_AFFINITY64; i++)
  627. ::EnableWindow(GetDlgItem(i), bEnable);
  628. ::EnableWindow(GetDlgItem(IDC_AFFINITY_CHK), !(m_bReadOnly || bForceDisable));
  629. }
  630. BOOL CAffinityWiz::OnSetActive()
  631. {
  632. if ( m_PageType == PROCESS_PAGE )
  633. {
  634. if (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_JOB_MEMBERSHIP)
  635. ApplyControlEnableRules(TRUE);
  636. else
  637. ApplyControlEnableRules(FALSE);
  638. }
  639. return TRUE;
  640. }
  641. LRESULT CAffinityWiz::OnAffinityEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  642. {
  643. if (wNotifyCode == BN_CLICKED)
  644. {
  645. ASSERT(wID >= IDC_AFFINITY1 && wID <= IDC_AFFINITY64);
  646. int bit = wID - IDC_AFFINITY1;
  647. UINT btnState = IsDlgButtonChecked(wID);
  648. if (btnState == BST_UNCHECKED)
  649. {
  650. if ( m_ProcessorMask & (ProcessorBit << bit))
  651. CheckDlgButton(wID, BST_CHECKED);
  652. else
  653. CheckDlgButton(wID, BST_INDETERMINATE);
  654. }
  655. else
  656. {
  657. CheckDlgButton(wID, BST_UNCHECKED);
  658. }
  659. }
  660. bHandled = FALSE;
  661. return 0;
  662. }
  663. LRESULT CAffinityWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  664. {
  665. if (wID == IDC_AFFINITY_CHK)
  666. {
  667. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_AFFINITY_CHK));
  668. for (int i = IDC_AFFINITY1; i <= IDC_AFFINITY64; i++)
  669. ::EnableWindow(GetDlgItem(i), checked);
  670. }
  671. bHandled = FALSE;
  672. return 0;
  673. }
  674. BOOL CAffinityWiz::OnWizardNext()
  675. {
  676. if (!UpdateData(TRUE) )
  677. return FALSE;
  678. return TRUE;
  679. }
  680. ///////////////////////////////////////////////////////////////////////////
  681. // Priority
  682. CPriorityWiz::CPriorityWiz(WIZ_POSITION pos, int nTitle, PCProcDetail *ProcDetail) :
  683. CMySnapInPropertyWizardImpl<CPriorityWiz>(pos, nTitle),
  684. m_PageType(PROCESS_PAGE), m_pProcDetail(ProcDetail), m_pJobDetail(NULL)
  685. {
  686. Initialize();
  687. }
  688. CPriorityWiz::CPriorityWiz(WIZ_POSITION pos, int nTitle, PCJobDetail *JobDetail) :
  689. CMySnapInPropertyWizardImpl<CPriorityWiz>(pos, nTitle),
  690. m_PageType(JOB_PAGE), m_pProcDetail(NULL), m_pJobDetail(JobDetail)
  691. {
  692. Initialize();
  693. }
  694. CPriorityWiz::~CPriorityWiz()
  695. {
  696. }
  697. void CPriorityWiz::Initialize()
  698. {
  699. ASSERT(m_PageType == PROCESS_PAGE && m_pProcDetail || m_PageType == JOB_PAGE && m_pJobDetail);
  700. m_bReadOnly = FALSE;
  701. }
  702. LRESULT CPriorityWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  703. {
  704. UINT nPromptID;
  705. if (m_PageType == PROCESS_PAGE)
  706. nPromptID = IDS_PRIORITY_JOBWARNING;
  707. else
  708. nPromptID = IDS_PRIORITY_NOJOBWARNING;
  709. CComBSTR bStr;
  710. if (bStr.LoadString(nPromptID))
  711. VERIFY(SetDlgItemText(IDC_PRIORITY_PROMPT, bStr.m_str));
  712. UpdateData(FALSE);
  713. bHandled = FALSE;
  714. return TRUE; // Let the system set the focus
  715. }
  716. LRESULT CPriorityWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  717. {
  718. HELPINFO *phi = (HELPINFO*) lParam;
  719. if (phi && phi->iContextType == HELPINFO_WINDOW)
  720. {
  721. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_priority);
  722. MMCPropertyHelp(pTopic);
  723. return TRUE;
  724. }
  725. bHandled = FALSE;
  726. return FALSE;
  727. }
  728. BOOL CPriorityWiz::UpdateData(BOOL bSaveAndValidate)
  729. {
  730. if (bSaveAndValidate)
  731. {
  732. BOOL prioritychk = (BST_CHECKED == IsDlgButtonChecked(IDC_PRIORITY_CHK));
  733. PRIORITY p = 0;
  734. for ( int i = IDC_LOW; i<= IDC_REALTIME; i++)
  735. {
  736. if ( BST_CHECKED == IsDlgButtonChecked(i) )
  737. p += IDToPriority(i);
  738. }
  739. if (IDToPriority(PriorityToID(p)) != p) //not fool proof, but do we really need to check this? no
  740. {
  741. MessageBeep(MB_ICONASTERISK);
  742. return FALSE;
  743. }
  744. if (m_PageType == PROCESS_PAGE)
  745. {
  746. m_pProcDetail->base.mgmtParms.priority = p;
  747. SetMGMTFlag(m_pProcDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_PRIORITY, prioritychk);
  748. }
  749. else if (m_PageType == JOB_PAGE)
  750. {
  751. m_pJobDetail->base.mgmtParms.priority = p;
  752. SetMGMTFlag(m_pJobDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_PRIORITY, prioritychk);
  753. }
  754. return TRUE;
  755. }
  756. else
  757. {
  758. BOOL prioritychk = FALSE;
  759. PRIORITY p = PCPrioNormal;
  760. if (m_PageType == PROCESS_PAGE)
  761. {
  762. if (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_PRIORITY)
  763. prioritychk = TRUE;
  764. m_pProcDetail->base.mgmtParms.priority = p;
  765. }
  766. else if (m_PageType == JOB_PAGE)
  767. {
  768. if (m_pJobDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_PRIORITY)
  769. prioritychk = TRUE;
  770. m_pJobDetail->base.mgmtParms.priority = p;
  771. }
  772. CheckDlgButton(IDC_PRIORITY_CHK, prioritychk ? BST_CHECKED : BST_UNCHECKED);
  773. CheckRadioButton(IDC_LOW, IDC_REALTIME, PriorityToID(p));
  774. ApplyControlEnableRules(FALSE);
  775. return TRUE;
  776. }
  777. }
  778. void CPriorityWiz::ApplyControlEnableRules(BOOL bForceDisable)
  779. {
  780. BOOL bEnable;
  781. if (m_bReadOnly || !(BST_CHECKED == IsDlgButtonChecked(IDC_PRIORITY_CHK)) || bForceDisable)
  782. bEnable = FALSE;
  783. else
  784. bEnable = TRUE;
  785. UINT ids[] = { IDC_REALTIME, IDC_HIGH, IDC_ABOVE_NORMAL, IDC_NORMAL, IDC_BELOW_NORMAL, IDC_LOW, 0 };
  786. for (int i = 0; ids[i]; i++)
  787. ::EnableWindow(GetDlgItem(ids[i]), bEnable);
  788. ::EnableWindow(GetDlgItem(IDC_PRIORITY_CHK), !(m_bReadOnly || bForceDisable));
  789. }
  790. BOOL CPriorityWiz::OnSetActive()
  791. {
  792. if ( m_PageType == PROCESS_PAGE )
  793. {
  794. if (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_JOB_MEMBERSHIP)
  795. ApplyControlEnableRules(TRUE);
  796. else
  797. ApplyControlEnableRules(FALSE);
  798. }
  799. return TRUE;
  800. }
  801. LRESULT CPriorityWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  802. {
  803. if (wID == IDC_PRIORITY_CHK)
  804. {
  805. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_PRIORITY_CHK));
  806. UINT ids[] = { IDC_REALTIME, IDC_HIGH, IDC_ABOVE_NORMAL, IDC_NORMAL, IDC_BELOW_NORMAL, IDC_LOW,0 };
  807. for (int i = 0; ids[i]; i++)
  808. ::EnableWindow(GetDlgItem(ids[i]), checked);
  809. }
  810. bHandled = FALSE;
  811. return 0;
  812. }
  813. BOOL CPriorityWiz::OnWizardNext()
  814. {
  815. if (!UpdateData(TRUE) )
  816. return FALSE;
  817. return TRUE;
  818. }
  819. ///////////////////////////////////////////////////////////////////////////
  820. // JobName
  821. CJobNameWiz::CJobNameWiz(WIZ_POSITION pos, int nTitle, PCJobDetail *JobDetail)
  822. : CMySnapInPropertyWizardImpl<CJobNameWiz>(pos, nTitle),
  823. m_pJobDetail(JobDetail)
  824. {
  825. ASSERT(m_pJobDetail);
  826. m_bReadOnly = FALSE;
  827. m_bNoNameChange = FALSE;
  828. }
  829. CJobNameWiz::~CJobNameWiz()
  830. {
  831. }
  832. LRESULT CJobNameWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  833. {
  834. UpdateData(FALSE);
  835. bHandled = FALSE;
  836. return TRUE; // Let the system set the focus
  837. }
  838. LRESULT CJobNameWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  839. {
  840. HELPINFO *phi = (HELPINFO*) lParam;
  841. if (phi && phi->iContextType == HELPINFO_WINDOW)
  842. {
  843. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_name);
  844. MMCPropertyHelp(pTopic);
  845. return TRUE;
  846. }
  847. bHandled = FALSE;
  848. return FALSE;
  849. }
  850. BOOL CJobNameWiz::UpdateData(BOOL bSaveAndValidate)
  851. {
  852. if (bSaveAndValidate)
  853. {
  854. CComBSTR bName;
  855. if (!GetDlgItemText( IDC_NAME, bName.m_str ) ||
  856. !IsValidName(bName, FALSE) )
  857. {
  858. HWND hWndCtl = GetDlgItem(IDC_NAME);
  859. if(hWndCtl)
  860. ::SetFocus(hWndCtl);
  861. ITEM_STR strOut;
  862. LoadStringHelper(strOut, IDS_JOBNAME_WARNING);
  863. MessageBox(strOut, NULL, MB_OK | MB_ICONWARNING);
  864. return FALSE;
  865. }
  866. CComBSTR bComment;
  867. if ( !GetDlgItemText(IDC_COMMENT, bComment.m_str) )
  868. bComment = _T("");
  869. if (bComment.Length() > RULE_DESCRIPTION_LEN)
  870. {
  871. HWND hWndCtl = GetDlgItem(IDC_COMMENT);
  872. if(hWndCtl)
  873. ::SetFocus(hWndCtl);
  874. MessageBeep(MB_ICONASTERISK);
  875. return FALSE;
  876. }
  877. // everything validated so save
  878. _tcscpy(m_pJobDetail->base.jobName, bName);
  879. _tcscpy(m_pJobDetail->base.mgmtParms.description, bComment);
  880. return TRUE;
  881. }
  882. else
  883. {
  884. VERIFY(SetDlgItemText( IDC_NAME, m_pJobDetail->base.jobName ));
  885. SendDlgItemMessage( IDC_NAME, EM_SETLIMITTEXT, JOB_NAME_LEN, 0);
  886. VERIFY(SetDlgItemText( IDC_COMMENT, m_pJobDetail->base.mgmtParms.description ));
  887. SendDlgItemMessage( IDC_COMMENT, EM_SETLIMITTEXT, RULE_DESCRIPTION_LEN, 0);
  888. if (m_bReadOnly)
  889. {
  890. DisableControl(IDC_NAME);
  891. DisableControl(IDC_COMMENT);
  892. }
  893. if (m_bNoNameChange)
  894. DisableControl(IDC_NAME);
  895. return TRUE;
  896. }
  897. }
  898. BOOL CJobNameWiz::OnWizardNext()
  899. {
  900. if (!UpdateData(TRUE) )
  901. return FALSE;
  902. return TRUE;
  903. }
  904. ///////////////////////////////////////////////////////////////////////////
  905. // CSchedulingClassWiz
  906. CSchedulingClassWiz::CSchedulingClassWiz(WIZ_POSITION pos, int nTitle, SCHEDULING_CLASS *sclass, bool *chk)
  907. : CMySnapInPropertyWizardImpl<CSchedulingClassWiz>(pos, nTitle), m_schedClass(*sclass), m_schedClasschk(*chk)
  908. {
  909. m_bReadOnly = FALSE;
  910. m_schedClass = 5;
  911. m_schedClasschk = FALSE;
  912. }
  913. CSchedulingClassWiz::~CSchedulingClassWiz()
  914. {
  915. }
  916. LRESULT CSchedulingClassWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  917. {
  918. UpdateData(FALSE);
  919. bHandled = FALSE;
  920. return TRUE; // Let the system set the focus
  921. }
  922. LRESULT CSchedulingClassWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  923. {
  924. HELPINFO *phi = (HELPINFO*) lParam;
  925. if (phi && phi->iContextType == HELPINFO_WINDOW)
  926. {
  927. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_sch);
  928. MMCPropertyHelp(pTopic);
  929. return TRUE;
  930. }
  931. bHandled = FALSE;
  932. return FALSE;
  933. }
  934. BOOL CSchedulingClassWiz::UpdateData(BOOL bSaveAndValidate)
  935. {
  936. if (bSaveAndValidate)
  937. {
  938. LRESULT pos = SendDlgItemMessage(IDC_SPIN, UDM_GETPOS, 0, 0);
  939. if (0 == HIWORD(pos) && LOWORD(pos) >= 0 && LOWORD(pos) <= 9 )
  940. {
  941. m_schedClass = (SCHEDULING_CLASS) LOWORD(pos);
  942. m_schedClasschk = (BST_CHECKED == IsDlgButtonChecked(IDC_SCHEDULING_CHK));
  943. return TRUE;
  944. }
  945. HWND hWndCtl = GetDlgItem(IDC_SCLASS);
  946. if(hWndCtl)
  947. ::SetFocus(hWndCtl);
  948. MessageBeep(MB_ICONASTERISK);
  949. return FALSE;
  950. }
  951. else
  952. {
  953. CheckDlgButton(IDC_SCHEDULING_CHK, m_schedClasschk ? BST_CHECKED : BST_UNCHECKED);
  954. SendDlgItemMessage(IDC_SPIN, UDM_SETPOS, 0, MAKELONG(m_schedClass, 0) );
  955. SendDlgItemMessage(IDC_SPIN, UDM_SETRANGE32, 0, 9);
  956. if (m_bReadOnly || !m_schedClasschk)
  957. {
  958. DisableControl(IDC_SCLASS);
  959. DisableControl(IDC_SPIN);
  960. }
  961. if (m_bReadOnly)
  962. DisableControl(IDC_SCHEDULING_CHK);
  963. return TRUE;
  964. }
  965. }
  966. LRESULT CSchedulingClassWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  967. {
  968. if (wID == IDC_SCHEDULING_CHK)
  969. {
  970. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_SCHEDULING_CHK));
  971. ::EnableWindow(GetDlgItem(IDC_SCLASS), checked);
  972. ::EnableWindow(GetDlgItem(IDC_SPIN), checked);
  973. }
  974. bHandled = FALSE;
  975. return 0;
  976. }
  977. BOOL CSchedulingClassWiz::OnWizardNext()
  978. {
  979. if (!UpdateData(TRUE) )
  980. return FALSE;
  981. return TRUE;
  982. }
  983. ///////////////////////////////////////////////////////////////////////////
  984. // CWorkingSetWiz
  985. CWorkingSetWiz::CWorkingSetWiz(WIZ_POSITION pos, int nTitle, PCProcDetail *ProcDetail)
  986. : CMySnapInPropertyWizardImpl<CWorkingSetWiz>(pos, nTitle), m_pProcDetail(ProcDetail), m_pJobDetail(NULL)
  987. {
  988. Initialize();
  989. }
  990. CWorkingSetWiz::CWorkingSetWiz(WIZ_POSITION pos, int nTitle, PCJobDetail *JobDetail)
  991. : CMySnapInPropertyWizardImpl<CWorkingSetWiz>(pos, nTitle), m_pProcDetail(NULL), m_pJobDetail(JobDetail)
  992. {
  993. Initialize();
  994. }
  995. void CWorkingSetWiz::Initialize()
  996. {
  997. m_bReadOnly = FALSE;
  998. }
  999. CWorkingSetWiz::~CWorkingSetWiz()
  1000. {
  1001. }
  1002. LRESULT CWorkingSetWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1003. {
  1004. UpdateData(FALSE);
  1005. bHandled = FALSE;
  1006. return TRUE; // Let the system set the focus
  1007. }
  1008. LRESULT CWorkingSetWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1009. {
  1010. HELPINFO *phi = (HELPINFO*) lParam;
  1011. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1012. {
  1013. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_mem);
  1014. if (m_pProcDetail)
  1015. pTopic = const_cast<TCHAR*>(HELP_ru_workset);
  1016. MMCPropertyHelp(pTopic);
  1017. return TRUE;
  1018. }
  1019. bHandled = FALSE;
  1020. return FALSE;
  1021. }
  1022. BOOL CWorkingSetWiz::Validate(BOOL bSave)
  1023. {
  1024. LONG_PTR PosErr = 0;
  1025. MEMORY_VALUE minWS;
  1026. MEMORY_VALUE maxWS;
  1027. BOOL WSchk = (BST_CHECKED == IsDlgButtonChecked(IDC_WORKINGSET_CHK));
  1028. minWS = SendDlgItemMessage(IDC_MINWS_SPIN, UDM_GETPOS32, 0, (LPARAM) &PosErr);
  1029. if (PosErr || minWS > MAXLONG - 1 || (WSchk && minWS <= 0) )
  1030. {
  1031. HWND hWndCtl = GetDlgItem(IDC_MINWS);
  1032. if(hWndCtl)
  1033. ::SetFocus(hWndCtl);
  1034. ITEM_STR strOut;
  1035. LoadStringHelper(strOut, IDS_WSMINMAX_WARNING);
  1036. MessageBox(strOut, NULL, MB_OK | MB_ICONWARNING);
  1037. return FALSE;
  1038. }
  1039. maxWS = SendDlgItemMessage(IDC_MAXWS_SPIN, UDM_GETPOS32, 0, (LPARAM) &PosErr);
  1040. if (PosErr || maxWS > MAXLONG - 1 || (WSchk && minWS >= maxWS) )
  1041. {
  1042. HWND hWndCtl = GetDlgItem(IDC_MAXWS);
  1043. if(hWndCtl)
  1044. ::SetFocus(hWndCtl);
  1045. ITEM_STR strOut;
  1046. LoadStringHelper(strOut, IDS_WSMINMAX_WARNING);
  1047. MessageBox(strOut, NULL, MB_OK | MB_ICONWARNING);
  1048. return FALSE;
  1049. }
  1050. if (bSave)
  1051. {
  1052. if (m_pProcDetail)
  1053. {
  1054. SetMGMTFlag(m_pProcDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_WS_MINMAX, WSchk);
  1055. m_pProcDetail->base.mgmtParms.minWS = minWS *1024;
  1056. m_pProcDetail->base.mgmtParms.maxWS = maxWS *1024;
  1057. }
  1058. else if (m_pJobDetail)
  1059. {
  1060. SetMGMTFlag(m_pJobDetail->base.mgmtParms.mFlags, PCMFLAG_APPLY_WS_MINMAX, WSchk);
  1061. m_pJobDetail->base.mgmtParms.minWS = minWS * 1024;
  1062. m_pJobDetail->base.mgmtParms.maxWS = maxWS * 1024;
  1063. }
  1064. }
  1065. return TRUE;
  1066. }
  1067. BOOL CWorkingSetWiz::UpdateData(BOOL bSaveAndValidate)
  1068. {
  1069. if (bSaveAndValidate)
  1070. {
  1071. return Validate(TRUE);
  1072. }
  1073. else
  1074. {
  1075. BOOL WSchk = FALSE;
  1076. MEMORY_VALUE minWS = 0;
  1077. MEMORY_VALUE maxWS = 0;
  1078. if (m_pProcDetail)
  1079. {
  1080. WSchk = m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_WS_MINMAX;
  1081. minWS = m_pProcDetail->base.mgmtParms.minWS;
  1082. maxWS = m_pProcDetail->base.mgmtParms.maxWS;
  1083. }
  1084. else if (m_pJobDetail)
  1085. {
  1086. WSchk = m_pJobDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_WS_MINMAX;
  1087. minWS = m_pJobDetail->base.mgmtParms.minWS;
  1088. maxWS = m_pJobDetail->base.mgmtParms.maxWS;
  1089. }
  1090. if ( minWS/1024 > (MAXLONG - 1) ||
  1091. maxWS/1024 > (MAXLONG - 1) )
  1092. m_bReadOnly = TRUE;
  1093. long minWSInK = (long) (minWS/1024);
  1094. long maxWSInK = (long) (maxWS/1024);
  1095. CheckDlgButton(IDC_WORKINGSET_CHK, WSchk ? BST_CHECKED : BST_UNCHECKED);
  1096. SendDlgItemMessage(IDC_MINWS_SPIN, UDM_SETRANGE32, 0, MAXLONG - 1 );
  1097. SendDlgItemMessage(IDC_MINWS_SPIN, UDM_SETPOS32, 0, minWSInK );
  1098. SendDlgItemMessage(IDC_MAXWS_SPIN, UDM_SETRANGE32, 0, MAXLONG - 1 );
  1099. SendDlgItemMessage(IDC_MAXWS_SPIN, UDM_SETPOS32, 0, maxWSInK );
  1100. ApplyControlEnableRules(FALSE);
  1101. return TRUE;
  1102. }
  1103. }
  1104. void CWorkingSetWiz::ApplyControlEnableRules(BOOL bForceDisable)
  1105. {
  1106. BOOL bEnable;
  1107. if (m_bReadOnly || !(BST_CHECKED == IsDlgButtonChecked(IDC_WORKINGSET_CHK)) || bForceDisable)
  1108. bEnable = FALSE;
  1109. else
  1110. bEnable = TRUE;
  1111. UINT ids[] = { IDC_MINWS, IDC_MAXWS, IDC_MINWS_SPIN, IDC_MAXWS_SPIN, 0 };
  1112. for (int i = 0; ids[i]; i++)
  1113. ::EnableWindow(GetDlgItem(ids[i]), bEnable);
  1114. ::EnableWindow(GetDlgItem(IDC_WORKINGSET_CHK), !(m_bReadOnly || bForceDisable));
  1115. }
  1116. BOOL CWorkingSetWiz::OnSetActive()
  1117. {
  1118. if ( m_pProcDetail )
  1119. {
  1120. if (m_pProcDetail->base.mgmtParms.mFlags & PCMFLAG_APPLY_JOB_MEMBERSHIP)
  1121. ApplyControlEnableRules(TRUE);
  1122. else
  1123. ApplyControlEnableRules(FALSE);
  1124. }
  1125. return TRUE;
  1126. }
  1127. LRESULT CWorkingSetWiz::OnSpin(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  1128. {
  1129. if (idCtrl == IDC_MINWS_SPIN ||
  1130. idCtrl == IDC_MAXWS_SPIN )
  1131. {
  1132. NMUPDOWN * nmupdown = (NMUPDOWN *) pnmh;
  1133. __int64 value = (__int64) nmupdown->iPos + 1024 * (__int64) nmupdown->iDelta;
  1134. if ( value <= MAXLONG - 1 )
  1135. nmupdown->iDelta *= 1024;
  1136. }
  1137. bHandled = FALSE;
  1138. return 0;
  1139. }
  1140. LRESULT CWorkingSetWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1141. {
  1142. if (wID == IDC_WORKINGSET_CHK)
  1143. {
  1144. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_WORKINGSET_CHK));
  1145. ::EnableWindow(GetDlgItem(IDC_MINWS), checked);
  1146. ::EnableWindow(GetDlgItem(IDC_MAXWS), checked);
  1147. ::EnableWindow(GetDlgItem(IDC_MINWS_SPIN), checked);
  1148. ::EnableWindow(GetDlgItem(IDC_MAXWS_SPIN), checked);
  1149. }
  1150. bHandled = FALSE;
  1151. return 0;
  1152. }
  1153. BOOL CWorkingSetWiz::OnWizardNext()
  1154. {
  1155. if (!UpdateData(TRUE) )
  1156. return FALSE;
  1157. return TRUE;
  1158. }
  1159. ///////////////////////////////////////////////////////////////////////////
  1160. // CCommittedMemoryWiz
  1161. CCommittedMemoryWiz::CCommittedMemoryWiz(WIZ_POSITION pos, int nTitle, MEMORY_VALUE *procmemorylimit, bool *procmemorylimitchk, MEMORY_VALUE *jobmemorylimit, bool *jobmemorylimitchk) :
  1162. CMySnapInPropertyWizardImpl<CCommittedMemoryWiz>(pos, nTitle),
  1163. m_procmemorylimit(*procmemorylimit), m_procmemorylimitchk(*procmemorylimitchk),
  1164. m_jobmemorylimit(*jobmemorylimit), m_jobmemorylimitchk(*jobmemorylimitchk)
  1165. {
  1166. m_bReadOnly = FALSE;
  1167. m_procmemorylimitchk = m_jobmemorylimitchk = FALSE;
  1168. m_procmemorylimit = m_jobmemorylimit = 0;
  1169. }
  1170. CCommittedMemoryWiz::~CCommittedMemoryWiz()
  1171. {
  1172. }
  1173. LRESULT CCommittedMemoryWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1174. {
  1175. UpdateData(FALSE);
  1176. bHandled = FALSE;
  1177. return TRUE; // Let the system set the focus
  1178. }
  1179. LRESULT CCommittedMemoryWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1180. {
  1181. HELPINFO *phi = (HELPINFO*) lParam;
  1182. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1183. {
  1184. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_mem);
  1185. MMCPropertyHelp(pTopic);
  1186. return TRUE;
  1187. }
  1188. bHandled = FALSE;
  1189. return FALSE;
  1190. }
  1191. BOOL CCommittedMemoryWiz::Validate(BOOL bSave)
  1192. {
  1193. LONG_PTR PosErr = 0;
  1194. MEMORY_VALUE procmemorylimit;
  1195. MEMORY_VALUE jobmemorylimit;
  1196. procmemorylimit = SendDlgItemMessage(IDC_PROC_SPIN, UDM_GETPOS32, 0, (LPARAM) &PosErr);
  1197. if (PosErr || procmemorylimit > MAXLONG - 1)
  1198. {
  1199. HWND hWndCtl = GetDlgItem(IDC_PROCMEMORY);
  1200. if(hWndCtl)
  1201. ::SetFocus(hWndCtl);
  1202. MessageBeep(MB_ICONASTERISK);
  1203. return FALSE;
  1204. }
  1205. jobmemorylimit = SendDlgItemMessage(IDC_JOB_SPIN, UDM_GETPOS32, 0, (LPARAM) &PosErr);
  1206. if (PosErr || jobmemorylimit > MAXLONG - 1)
  1207. {
  1208. HWND hWndCtl = GetDlgItem(IDC_JOBMEMORY);
  1209. if(hWndCtl)
  1210. ::SetFocus(hWndCtl);
  1211. MessageBeep(MB_ICONASTERISK);
  1212. return FALSE;
  1213. }
  1214. if (bSave)
  1215. {
  1216. m_procmemorylimitchk = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCMEMORY_CHK));
  1217. m_procmemorylimit = procmemorylimit * 1024;
  1218. m_jobmemorylimitchk = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBMEMORY_CHK));
  1219. m_jobmemorylimit = jobmemorylimit * 1024;
  1220. }
  1221. return TRUE;
  1222. }
  1223. BOOL CCommittedMemoryWiz::UpdateData(BOOL bSaveAndValidate)
  1224. {
  1225. if (bSaveAndValidate)
  1226. {
  1227. return Validate(TRUE);
  1228. }
  1229. else
  1230. {
  1231. if ( m_procmemorylimit/1024 > (MAXLONG - 1) ||
  1232. m_jobmemorylimit/1024 > (MAXLONG - 1) )
  1233. m_bReadOnly = TRUE;
  1234. long ProcMemInK = (long) (m_procmemorylimit/1024);
  1235. long JobMemInK = (long) (m_jobmemorylimit/1024);
  1236. CheckDlgButton(IDC_PROCMEMORY_CHK, m_procmemorylimitchk ? BST_CHECKED : BST_UNCHECKED);
  1237. SendDlgItemMessage(IDC_PROC_SPIN, UDM_SETRANGE32, 0, MAXLONG - 1);
  1238. SendDlgItemMessage(IDC_PROC_SPIN, UDM_SETPOS32, 0, ProcMemInK );
  1239. CheckDlgButton(IDC_JOBMEMORY_CHK, m_jobmemorylimitchk ? BST_CHECKED : BST_UNCHECKED);
  1240. SendDlgItemMessage(IDC_JOB_SPIN, UDM_SETRANGE32, 0, MAXLONG - 1);
  1241. SendDlgItemMessage(IDC_JOB_SPIN, UDM_SETPOS32, 0, JobMemInK );
  1242. if (m_bReadOnly || !m_procmemorylimitchk)
  1243. DisableControl(IDC_PROCMEMORY);
  1244. if (m_bReadOnly || !m_jobmemorylimitchk)
  1245. DisableControl(IDC_JOBMEMORY);
  1246. if (m_bReadOnly)
  1247. {
  1248. DisableControl(IDC_PROCMEMORY_CHK);
  1249. DisableControl(IDC_JOBMEMORY_CHK);
  1250. }
  1251. return TRUE;
  1252. }
  1253. }
  1254. LRESULT CCommittedMemoryWiz::OnSpin(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  1255. {
  1256. if (idCtrl == IDC_PROC_SPIN ||
  1257. idCtrl == IDC_JOB_SPIN )
  1258. {
  1259. NMUPDOWN * nmupdown = (NMUPDOWN *) pnmh;
  1260. __int64 value = (__int64) nmupdown->iPos + 1024 * (__int64) nmupdown->iDelta;
  1261. if ( value <= MAXLONG - 1 )
  1262. nmupdown->iDelta *= 1024;
  1263. }
  1264. bHandled = FALSE;
  1265. return 0;
  1266. }
  1267. LRESULT CCommittedMemoryWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1268. {
  1269. if (wID == IDC_PROCMEMORY_CHK)
  1270. {
  1271. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCMEMORY_CHK));
  1272. ::EnableWindow(GetDlgItem(IDC_PROCMEMORY), checked);
  1273. ::EnableWindow(GetDlgItem(IDC_PROC_SPIN), checked);
  1274. }
  1275. else if (wID == IDC_JOBMEMORY_CHK)
  1276. {
  1277. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBMEMORY_CHK));
  1278. ::EnableWindow(GetDlgItem(IDC_JOBMEMORY), checked);
  1279. ::EnableWindow(GetDlgItem(IDC_JOB_SPIN), checked);
  1280. }
  1281. bHandled = FALSE;
  1282. return 0;
  1283. }
  1284. BOOL CCommittedMemoryWiz::OnWizardNext()
  1285. {
  1286. if (!UpdateData(TRUE) )
  1287. return FALSE;
  1288. return TRUE;
  1289. }
  1290. ///////////////////////////////////////////////////////////////////////////
  1291. // CProcCountWiz
  1292. CProcCountWiz::CProcCountWiz(WIZ_POSITION pos, int nTitle, PROC_COUNT *processcount, bool *processcountchk ) :
  1293. CMySnapInPropertyWizardImpl<CProcCountWiz>(pos, nTitle),
  1294. m_processcount(*processcount), m_processcountchk(*processcountchk)
  1295. {
  1296. m_bReadOnly = FALSE;
  1297. m_processcount = 0;
  1298. m_processcountchk = FALSE;
  1299. }
  1300. CProcCountWiz::~CProcCountWiz()
  1301. {
  1302. }
  1303. LRESULT CProcCountWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1304. {
  1305. UpdateData(FALSE);
  1306. bHandled = FALSE;
  1307. return TRUE; // Let the system set the focus
  1308. }
  1309. LRESULT CProcCountWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1310. {
  1311. HELPINFO *phi = (HELPINFO*) lParam;
  1312. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1313. {
  1314. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_procs);
  1315. MMCPropertyHelp(pTopic);
  1316. return TRUE;
  1317. }
  1318. bHandled = FALSE;
  1319. return FALSE;
  1320. }
  1321. BOOL CProcCountWiz::Validate(BOOL bSave)
  1322. {
  1323. LONG_PTR PosErr = 0;
  1324. LRESULT processcount = SendDlgItemMessage(IDC_SPIN, UDM_GETPOS32, 0, (LPARAM) &PosErr);
  1325. if (PosErr || processcount < 0)
  1326. {
  1327. HWND hWndCtl = GetDlgItem(IDC_PROCESSCOUNT);
  1328. if(hWndCtl)
  1329. ::SetFocus(hWndCtl);
  1330. MessageBeep(MB_ICONASTERISK);
  1331. return FALSE;
  1332. }
  1333. if (bSave)
  1334. {
  1335. m_processcountchk = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCESSCOUNT_CHK));
  1336. m_processcount = (PROC_COUNT) processcount;
  1337. }
  1338. return TRUE;
  1339. }
  1340. BOOL CProcCountWiz::UpdateData(BOOL bSaveAndValidate)
  1341. {
  1342. if (bSaveAndValidate)
  1343. {
  1344. return Validate(TRUE);
  1345. }
  1346. else
  1347. {
  1348. CheckDlgButton(IDC_PROCESSCOUNT_CHK, m_processcountchk ? BST_CHECKED : BST_UNCHECKED);
  1349. SendDlgItemMessage(IDC_SPIN, UDM_SETRANGE32, 0, MAXLONG-1);
  1350. SendDlgItemMessage(IDC_SPIN, UDM_SETPOS32, 0, m_processcount );
  1351. if (m_bReadOnly || !m_processcountchk)
  1352. {
  1353. DisableControl(IDC_PROCESSCOUNT);
  1354. DisableControl(IDC_SPIN);
  1355. }
  1356. if (m_bReadOnly)
  1357. DisableControl(IDC_PROCESSCOUNT_CHK);
  1358. return TRUE;
  1359. }
  1360. }
  1361. LRESULT CProcCountWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1362. {
  1363. if (wID == IDC_PROCESSCOUNT_CHK)
  1364. {
  1365. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCESSCOUNT_CHK));
  1366. ::EnableWindow(GetDlgItem(IDC_PROCESSCOUNT), checked);
  1367. ::EnableWindow(GetDlgItem(IDC_SPIN), checked);
  1368. }
  1369. bHandled = FALSE;
  1370. return 0;
  1371. }
  1372. BOOL CProcCountWiz::OnWizardNext()
  1373. {
  1374. if (!UpdateData(TRUE) )
  1375. return FALSE;
  1376. return TRUE;
  1377. }
  1378. ///////////////////////////////////////////////////////////////////////////
  1379. // CTimeWiz
  1380. CTimeWiz::CTimeWiz(WIZ_POSITION pos, int nTitle,
  1381. TIME_VALUE *procusertime, bool *procusertimechk,
  1382. TIME_VALUE *jobusertime, bool *jobusertimechk, bool *jobmsgontimelimit) :
  1383. CMySnapInPropertyWizardImpl<CTimeWiz>(pos, nTitle),
  1384. m_procusertime(*procusertime), m_procusertimechk(*procusertimechk),
  1385. m_jobusertime(*jobusertime), m_jobusertimechk(*jobusertimechk), m_jobmsgontimelimit(*jobmsgontimelimit)
  1386. {
  1387. m_bReadOnly = FALSE;
  1388. m_procusertimechk = m_jobusertimechk = m_jobmsgontimelimit = FALSE;
  1389. m_procusertime = m_jobusertime = 0;
  1390. }
  1391. CTimeWiz::~CTimeWiz()
  1392. {
  1393. }
  1394. LRESULT CTimeWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1395. {
  1396. UpdateData(FALSE);
  1397. bHandled = FALSE;
  1398. return TRUE; // Let the system set the focus
  1399. }
  1400. LRESULT CTimeWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1401. {
  1402. HELPINFO *phi = (HELPINFO*) lParam;
  1403. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1404. {
  1405. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_time);
  1406. MMCPropertyHelp(pTopic);
  1407. return TRUE;
  1408. }
  1409. bHandled = FALSE;
  1410. return FALSE;
  1411. }
  1412. BOOL CTimeWiz::Validate(BOOL bSave)
  1413. {
  1414. TIME_VALUE procusertime;
  1415. TIME_VALUE jobusertime;
  1416. bool procusertimechk = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCUSERTIME_CHK));
  1417. bool jobusertimechk = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBUSERTIME_CHK));
  1418. if ( !ValidateTimeField(m_hWnd, IDC_PROCUSERTIME, procusertime) ||
  1419. (procusertimechk && procusertime < PC_MIN_TIME_LIMIT) )
  1420. {
  1421. HWND hWndCtl = GetDlgItem(IDC_PROCUSERTIME);
  1422. if(hWndCtl)
  1423. ::SetFocus(hWndCtl);
  1424. MessageBeep(MB_ICONASTERISK);
  1425. CComBSTR bTemp;
  1426. if (bTemp.LoadString(IDS_TIMEENTRY))
  1427. MessageBox(bTemp.m_str, NULL, MB_OK | MB_ICONWARNING);
  1428. return FALSE;
  1429. }
  1430. if ( !ValidateTimeField(m_hWnd, IDC_JOBUSERTIME, jobusertime) ||
  1431. (jobusertimechk && jobusertime < PC_MIN_TIME_LIMIT) )
  1432. {
  1433. HWND hWndCtl = GetDlgItem(IDC_JOBUSERTIME);
  1434. if(hWndCtl)
  1435. ::SetFocus(hWndCtl);
  1436. MessageBeep(MB_ICONASTERISK);
  1437. CComBSTR bTemp;
  1438. if (bTemp.LoadString(IDS_TIMEENTRY))
  1439. MessageBox(bTemp.m_str, NULL, MB_OK | MB_ICONWARNING);
  1440. return FALSE;
  1441. }
  1442. if (bSave)
  1443. {
  1444. m_procusertimechk = procusertimechk;
  1445. m_procusertime = procusertime;
  1446. m_jobusertimechk = jobusertimechk;
  1447. m_jobusertime = jobusertime;
  1448. m_jobmsgontimelimit = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBTIMELIMIT_MSG));
  1449. }
  1450. return TRUE;
  1451. }
  1452. BOOL CTimeWiz::UpdateData(BOOL bSaveAndValidate)
  1453. {
  1454. if (bSaveAndValidate)
  1455. {
  1456. return Validate(TRUE);
  1457. }
  1458. else
  1459. {
  1460. ITEM_STR str;
  1461. CheckDlgButton(IDC_PROCUSERTIME_CHK, m_procusertimechk ? BST_CHECKED : BST_UNCHECKED);
  1462. SetDlgItemText(IDC_PROCUSERTIME, FormatCNSTime(str, m_procusertime) );
  1463. CheckDlgButton(IDC_JOBUSERTIME_CHK, m_jobusertimechk ? BST_CHECKED : BST_UNCHECKED);
  1464. SetDlgItemText(IDC_JOBUSERTIME, FormatCNSTime(str, m_jobusertime) );
  1465. CheckRadioButton(IDC_JOBTIMELIMIT_TERM, IDC_JOBTIMELIMIT_MSG, m_jobmsgontimelimit ? IDC_JOBTIMELIMIT_MSG : IDC_JOBTIMELIMIT_TERM );
  1466. if (m_bReadOnly || !m_procusertimechk)
  1467. DisableControl(IDC_PROCUSERTIME);
  1468. if (m_bReadOnly || !m_jobusertimechk)
  1469. {
  1470. DisableControl(IDC_JOBUSERTIME);
  1471. DisableControl(IDC_JOBTIMELIMIT_TERM);
  1472. DisableControl(IDC_JOBTIMELIMIT_MSG);
  1473. }
  1474. if (m_bReadOnly)
  1475. {
  1476. DisableControl(IDC_PROCUSERTIME_CHK);
  1477. DisableControl(IDC_JOBUSERTIME_CHK);
  1478. }
  1479. return TRUE;
  1480. }
  1481. }
  1482. LRESULT CTimeWiz::OnChk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1483. {
  1484. if (wID == IDC_PROCUSERTIME_CHK)
  1485. {
  1486. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_PROCUSERTIME_CHK));
  1487. ::EnableWindow(GetDlgItem(IDC_PROCUSERTIME), checked);
  1488. }
  1489. else if (wID == IDC_JOBUSERTIME_CHK)
  1490. {
  1491. bool checked = (BST_CHECKED == IsDlgButtonChecked(IDC_JOBUSERTIME_CHK));
  1492. ::EnableWindow(GetDlgItem(IDC_JOBUSERTIME), checked);
  1493. ::EnableWindow(GetDlgItem(IDC_JOBTIMELIMIT_TERM), checked);
  1494. ::EnableWindow(GetDlgItem(IDC_JOBTIMELIMIT_MSG), checked);
  1495. }
  1496. bHandled = FALSE;
  1497. return 0;
  1498. }
  1499. BOOL CTimeWiz::OnWizardNext()
  1500. {
  1501. if (!UpdateData(TRUE) )
  1502. return FALSE;
  1503. return TRUE;
  1504. }
  1505. ///////////////////////////////////////////////////////////////////////////
  1506. // CAdvancedWiz
  1507. CAdvancedWiz::CAdvancedWiz(WIZ_POSITION pos, int nTitle, bool *endjob, bool *unhandledexcept ) :
  1508. CMySnapInPropertyWizardImpl<CAdvancedWiz>(pos, nTitle),
  1509. m_endjob(*endjob),m_unhandledexcept(*unhandledexcept)
  1510. {
  1511. m_bReadOnly = FALSE;
  1512. m_endjob = m_unhandledexcept = FALSE;
  1513. }
  1514. CAdvancedWiz::~CAdvancedWiz()
  1515. {
  1516. }
  1517. LRESULT CAdvancedWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1518. {
  1519. UpdateData(FALSE);
  1520. bHandled = FALSE;
  1521. return TRUE; // Let the system set the focus
  1522. }
  1523. LRESULT CAdvancedWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1524. {
  1525. HELPINFO *phi = (HELPINFO*) lParam;
  1526. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1527. {
  1528. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_adv);
  1529. MMCPropertyHelp(pTopic);
  1530. return TRUE;
  1531. }
  1532. bHandled = FALSE;
  1533. return FALSE;
  1534. }
  1535. BOOL CAdvancedWiz::Validate(BOOL bSave)
  1536. {
  1537. if (bSave)
  1538. {
  1539. m_endjob = (BST_CHECKED == IsDlgButtonChecked(IDC_ENDJOB_CHK));
  1540. m_unhandledexcept = (BST_CHECKED == IsDlgButtonChecked(IDC_UNHANDLEDEXCEPT_CHK));
  1541. }
  1542. return TRUE;
  1543. }
  1544. BOOL CAdvancedWiz::UpdateData(BOOL bSaveAndValidate)
  1545. {
  1546. if (bSaveAndValidate)
  1547. {
  1548. return Validate(TRUE);
  1549. }
  1550. else
  1551. {
  1552. CheckDlgButton(IDC_ENDJOB_CHK, m_endjob ? BST_CHECKED : BST_UNCHECKED);
  1553. CheckDlgButton(IDC_UNHANDLEDEXCEPT_CHK, m_unhandledexcept ? BST_CHECKED : BST_UNCHECKED);
  1554. if (m_bReadOnly)
  1555. {
  1556. DisableControl(IDC_ENDJOB_CHK);
  1557. DisableControl(IDC_UNHANDLEDEXCEPT_CHK);
  1558. }
  1559. return TRUE;
  1560. }
  1561. }
  1562. BOOL CAdvancedWiz::OnWizardNext()
  1563. {
  1564. if (!UpdateData(TRUE) )
  1565. return FALSE;
  1566. return TRUE;
  1567. }
  1568. ///////////////////////////////////////////////////////////////////////////
  1569. // CAdvBreakawayWiz
  1570. CAdvBreakawayWiz::CAdvBreakawayWiz(WIZ_POSITION pos, int nTitle, bool *breakaway, bool *silentbreakaway) :
  1571. CMySnapInPropertyWizardImpl<CAdvBreakawayWiz>(pos, nTitle),
  1572. m_breakaway(*breakaway), m_silentbreakaway(*silentbreakaway)
  1573. {
  1574. m_bReadOnly = FALSE;
  1575. m_breakaway = m_silentbreakaway = FALSE;
  1576. }
  1577. CAdvBreakawayWiz::~CAdvBreakawayWiz()
  1578. {
  1579. }
  1580. LRESULT CAdvBreakawayWiz::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1581. {
  1582. UpdateData(FALSE);
  1583. bHandled = FALSE;
  1584. return TRUE; // Let the system set the focus
  1585. }
  1586. LRESULT CAdvBreakawayWiz::OnWMHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1587. {
  1588. HELPINFO *phi = (HELPINFO*) lParam;
  1589. if (phi && phi->iContextType == HELPINFO_WINDOW)
  1590. {
  1591. TCHAR *pTopic = const_cast<TCHAR*>(HELP_ru_job_adv);
  1592. MMCPropertyHelp(pTopic);
  1593. return TRUE;
  1594. }
  1595. bHandled = FALSE;
  1596. return FALSE;
  1597. }
  1598. BOOL CAdvBreakawayWiz::Validate(BOOL bSave)
  1599. {
  1600. if (bSave)
  1601. {
  1602. m_breakaway = (BST_CHECKED == IsDlgButtonChecked(IDC_BREAKAWAY_CHK));
  1603. m_silentbreakaway = (BST_CHECKED == IsDlgButtonChecked(IDC_SILENTBREAKAWAY_CHK));
  1604. }
  1605. return TRUE;
  1606. }
  1607. BOOL CAdvBreakawayWiz::UpdateData(BOOL bSaveAndValidate)
  1608. {
  1609. if (bSaveAndValidate)
  1610. {
  1611. return Validate(TRUE);
  1612. }
  1613. else
  1614. {
  1615. CheckDlgButton(IDC_BREAKAWAY_CHK, m_breakaway ? BST_CHECKED : BST_UNCHECKED);
  1616. CheckDlgButton(IDC_SILENTBREAKAWAY_CHK, m_silentbreakaway ? BST_CHECKED : BST_UNCHECKED);
  1617. if (m_bReadOnly)
  1618. {
  1619. DisableControl(IDC_BREAKAWAY_CHK);
  1620. DisableControl(IDC_SILENTBREAKAWAY_CHK);
  1621. }
  1622. return TRUE;
  1623. }
  1624. }
  1625. BOOL CAdvBreakawayWiz::OnWizardNext()
  1626. {
  1627. if (!UpdateData(TRUE) )
  1628. return FALSE;
  1629. return TRUE;
  1630. }