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.

1030 lines
30 KiB

  1. /*
  2. ==============================================================================
  3. Application:
  4. Microsoft Windows NT (TM) Performance Monitor
  5. File:
  6. Command.c -- PerfmonCommand routine and helpers.
  7. This file contains the PerfmonCommand routine, which handles
  8. all of the user's menu selections.
  9. Copyright 1992-1993, Microsoft Corporation. All Rights Reserved.
  10. Microsoft Confidential.
  11. ==============================================================================
  12. */
  13. //==========================================================================//
  14. // Includes //
  15. //==========================================================================//
  16. #include "stdio.h"
  17. #include "perfmon.h"
  18. #include "command.h" // External declarations for this file
  19. #include <shellapi.h> // for ShellAbout
  20. #include "addlog.h" // for AddLog
  21. #include "alert.h" // for CurrentAlertLine
  22. #include "bookmark.h" // for AddBookmark
  23. #include "cderr.h"
  24. #include "datasrc.h" // for DisplayDataSourceOptions
  25. #include "dialogs.h"
  26. #include "dispoptn.h" // for DisplayDisplayOptions
  27. #include "fileopen.h" // for FileOpen
  28. #include "grafdata.h" // for ChartDeleteLine ClearGraphDisplay
  29. #include "grafdisp.h" // for ToggleGraphRefresh
  30. #include "graph.h" // for SizeGraphComponents
  31. #include "init.h" // for PerfmonClose
  32. #include "legend.h"
  33. #include "log.h" // for LogTimer
  34. #include "logoptns.h"
  35. #include "playback.h"
  36. #include "report.h" // for CurrentReportItem
  37. #include "rptoptns.h" // for DisplayReportOptions
  38. #include "status.h" // for StatusUpdateIcons
  39. #include "timefrm.h" // for SetTimeframe
  40. #include "toolbar.h" // for ToolbarDepressButton
  41. #include "utils.h"
  42. #include "perfmops.h" // for SaveWorkspace
  43. int static deltax ;
  44. int static deltay ;
  45. #define ABOUT_TIMER_ID 10
  46. INT_PTR
  47. FAR
  48. WINAPI
  49. AboutDlgProc (
  50. HWND hDlg,
  51. UINT iMessage,
  52. WPARAM wParam,
  53. LPARAM lParam
  54. )
  55. {
  56. BOOL bHandled ;
  57. bHandled = TRUE ;
  58. switch (iMessage) {
  59. case WM_INITDIALOG:
  60. deltax = 0 ;
  61. deltay = 0 ;
  62. dwCurrentDlgID = 0 ;
  63. SetTimer(hDlg, ABOUT_TIMER_ID, 1000, NULL) ;
  64. WindowCenter (hDlg) ;
  65. return (TRUE) ;
  66. case WM_TIMER:
  67. deltax += 2 ;
  68. if (deltax > 60)
  69. deltax = 0 ;
  70. deltay += 5 ;
  71. if (deltay > 60)
  72. deltay = 0 ;
  73. WindowInvalidate (DialogControl (hDlg, 524)) ;
  74. break ;
  75. case WM_DRAWITEM:
  76. {
  77. int xPos, yPos ;
  78. LPDRAWITEMSTRUCT lpItem ;
  79. lpItem = (LPDRAWITEMSTRUCT) lParam ;
  80. xPos = lpItem->rcItem.left + deltax ;
  81. yPos = lpItem->rcItem.top + deltay ;
  82. DrawIcon (lpItem->hDC, xPos, yPos, hIcon) ;
  83. }
  84. break ;
  85. case WM_CLOSE:
  86. dwCurrentDlgID = 0 ;
  87. KillTimer (hDlg, ABOUT_TIMER_ID) ;
  88. EndDialog (hDlg, 1) ;
  89. break ;
  90. case WM_COMMAND:
  91. switch (wParam) {
  92. case IDD_OK:
  93. dwCurrentDlgID = 0 ;
  94. EndDialog (hDlg, 1) ;
  95. break ;
  96. default:
  97. bHandled = FALSE ;
  98. break;
  99. }
  100. break;
  101. default:
  102. bHandled = FALSE ;
  103. break ;
  104. }
  105. return (bHandled) ;
  106. }
  107. //==========================================================================//
  108. // Local Functions //
  109. //==========================================================================//
  110. void
  111. ChangeView (
  112. HWND hWnd,
  113. int iNewView
  114. )
  115. {
  116. HMENU hMenu = GetMenu (hWnd) ;
  117. BOOL bViewChart, bViewAlert, bViewLog, bViewReport ;
  118. #ifdef ADVANCED_PERFMON
  119. iPerfmonView = iNewView ;
  120. bViewChart = bViewAlert = bViewLog = bViewReport = FALSE;
  121. switch (iNewView) {
  122. case IDM_VIEWCHART:
  123. bViewChart = TRUE ;
  124. break ;
  125. case IDM_VIEWALERT:
  126. bViewAlert = TRUE ;
  127. break ;
  128. case IDM_VIEWLOG:
  129. bViewLog = TRUE ;
  130. break ;
  131. case IDM_VIEWREPORT:
  132. bViewReport = TRUE ;
  133. break ;
  134. }
  135. WindowShow (hWndGraph, bViewChart) ;
  136. WindowShow (hWndAlert, bViewAlert) ;
  137. WindowShow (hWndLog, bViewLog) ;
  138. WindowShow (hWndReport, bViewReport) ;
  139. // set focus on the Legend window
  140. if (iPerfmonView == IDM_VIEWCHART) {
  141. SetFocus (hWndGraphLegend) ;
  142. } else if (iPerfmonView == IDM_VIEWALERT) {
  143. SetFocus (hWndAlertLegend) ;
  144. } else if (iPerfmonView == IDM_VIEWLOG) {
  145. SetFocus (hWndLogEntries) ;
  146. } else if (iPerfmonView == IDM_VIEWREPORT) {
  147. SetFocus (hWndReport) ;
  148. }
  149. if (hMenu) {
  150. MenuCheck (hMenu, IDM_VIEWCHART, bViewChart) ;
  151. MenuCheck (hMenu, IDM_VIEWALERT, bViewAlert) ;
  152. MenuCheck (hMenu, IDM_VIEWLOG, bViewLog) ;
  153. MenuCheck (hMenu, IDM_VIEWREPORT, bViewReport) ;
  154. // show the Title bar
  155. ShowPerfmonWindowText () ;
  156. }
  157. ToolbarDepressButton (hWndToolbar, ChartTool, bViewChart) ;
  158. ToolbarDepressButton (hWndToolbar, AlertTool, bViewAlert) ;
  159. ToolbarDepressButton (hWndToolbar, LogTool, bViewLog) ;
  160. ToolbarDepressButton (hWndToolbar, ReportTool, bViewReport) ;
  161. #else
  162. // only Chart view in Perfmon Lite
  163. iPerfmonView = IDM_VIEWCHART ;
  164. WindowShow (hWndGraph, TRUE) ;
  165. #endif
  166. DrawMenuBar(hWnd) ;
  167. StatusLineReady (hWndStatus) ;
  168. }
  169. //==========================================================================//
  170. // Message Handlers //
  171. //==========================================================================//
  172. void
  173. ViewChart (
  174. HWND hWnd
  175. )
  176. {
  177. if (Options.bMenubar)
  178. SetMenu (hWnd, hMenuChart) ;
  179. ChangeView (hWnd, IDM_VIEWCHART) ;
  180. }
  181. void
  182. ViewAlert (
  183. HWND hWnd
  184. )
  185. {
  186. iUnviewedAlerts = 0 ;
  187. StatusUpdateIcons (hWndStatus) ;
  188. if (Options.bMenubar)
  189. SetMenu (hWnd, hMenuAlert) ;
  190. ChangeView (hWnd, IDM_VIEWALERT) ;
  191. }
  192. void
  193. ViewLog (
  194. HWND hWnd
  195. )
  196. {
  197. if (Options.bMenubar)
  198. SetMenu (hWnd, hMenuLog) ;
  199. ChangeView (hWnd, IDM_VIEWLOG) ;
  200. }
  201. void
  202. ViewReport (
  203. HWND hWnd
  204. )
  205. {
  206. if (Options.bMenubar)
  207. SetMenu (hWnd, hMenuReport) ;
  208. ChangeView (hWnd, IDM_VIEWREPORT) ;
  209. }
  210. #ifdef KEEP_MANUALREFRESH
  211. void
  212. ToggleRefresh (
  213. HWND hWnd
  214. )
  215. {
  216. BOOL bRefresh ;
  217. switch (iPerfmonView) {
  218. case IDM_VIEWCHART:
  219. bRefresh = ToggleGraphRefresh (hWndGraph) ;
  220. break ;
  221. case IDM_VIEWALERT:
  222. bRefresh = ToggleAlertRefresh (hWndAlert) ;
  223. break ;
  224. case IDM_VIEWLOG:
  225. bRefresh = ToggleLogRefresh (hWndLog) ;
  226. break ;
  227. case IDM_VIEWREPORT:
  228. bRefresh = ToggleReportRefresh (hWndReport) ;
  229. break ;
  230. }
  231. MenuCheck (GetMenu (hWnd), IDM_OPTIONSMANUALREFRESH, bRefresh) ;
  232. }
  233. #endif
  234. //==========================================================================//
  235. // Exported Functions //
  236. //==========================================================================//
  237. BOOL
  238. PerfmonCommand (
  239. HWND hWnd,
  240. WPARAM wParam,
  241. LPARAM lParam
  242. )
  243. /*
  244. Effect: Respond to the user's menu selection, found in wParam.
  245. In particular, branch to the appropriate OnXXX function
  246. to perform the action associated with each command.
  247. Called By: MainWndProc (perfmon.c), in response to a WM_COMMAND
  248. message.
  249. */
  250. {
  251. PLINESTRUCT pLine ;
  252. BOOL bPrepareMenu = TRUE ;
  253. switch (LOWORD (wParam)) {
  254. //=============================//
  255. // Toolbar Commands //
  256. //=============================//
  257. case IDM_TOOLBARADD:
  258. bPrepareMenu = FALSE ;
  259. switch (iPerfmonView) {
  260. case IDM_VIEWCHART:
  261. SendMessage (hWnd, WM_COMMAND, IDM_EDITADDCHART, lParam) ;
  262. break ;
  263. case IDM_VIEWALERT:
  264. SendMessage (hWnd, WM_COMMAND, IDM_EDITADDALERT, lParam) ;
  265. break ;
  266. case IDM_VIEWLOG:
  267. SendMessage (hWnd, WM_COMMAND, IDM_EDITADDLOG, lParam) ;
  268. break ;
  269. case IDM_VIEWREPORT:
  270. SendMessage (hWnd, WM_COMMAND, IDM_EDITADDREPORT, lParam) ;
  271. break ;
  272. }
  273. break ;
  274. case IDM_TOOLBARMODIFY:
  275. bPrepareMenu = FALSE ;
  276. switch (iPerfmonView) {
  277. case IDM_VIEWCHART:
  278. SendMessage (hWnd, WM_COMMAND, IDM_EDITMODIFYCHART, lParam) ;
  279. break ;
  280. case IDM_VIEWALERT:
  281. SendMessage (hWnd, WM_COMMAND, IDM_EDITMODIFYALERT, lParam) ;
  282. break ;
  283. case IDM_VIEWREPORT:
  284. SendMessage (hWnd, WM_COMMAND, IDM_EDITMODIFYREPORT, lParam) ;
  285. break ;
  286. }
  287. break ;
  288. case IDM_TOOLBARDELETE:
  289. bPrepareMenu = FALSE ;
  290. switch (iPerfmonView) {
  291. case IDM_VIEWCHART:
  292. SendMessage (hWnd, WM_COMMAND, IDM_EDITDELETECHART, lParam) ;
  293. break ;
  294. case IDM_VIEWALERT:
  295. SendMessage (hWnd, WM_COMMAND, IDM_EDITDELETEALERT, lParam) ;
  296. break ;
  297. case IDM_VIEWLOG:
  298. SendMessage (hWnd, WM_COMMAND, IDM_EDITDELETELOG, lParam) ;
  299. break ;
  300. case IDM_VIEWREPORT:
  301. SendMessage (hWnd, WM_COMMAND, IDM_EDITDELETEREPORT, lParam) ;
  302. break ;
  303. }
  304. break ;
  305. case IDM_TOOLBARREFRESH:
  306. bPrepareMenu = FALSE ;
  307. switch (iPerfmonView) {
  308. case IDM_VIEWCHART:
  309. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREFRESHNOWCHART, lParam) ;
  310. break ;
  311. case IDM_VIEWALERT:
  312. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREFRESHNOWALERT, lParam) ;
  313. break ;
  314. case IDM_VIEWLOG:
  315. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREFRESHNOWLOG, lParam) ;
  316. break ;
  317. case IDM_VIEWREPORT:
  318. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREFRESHNOWREPORT, lParam) ;
  319. break ;
  320. }
  321. break ;
  322. case IDM_TOOLBAROPTIONS:
  323. bPrepareMenu = FALSE ;
  324. switch (iPerfmonView) {
  325. case IDM_VIEWCHART:
  326. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSCHART, lParam) ;
  327. break ;
  328. case IDM_VIEWALERT:
  329. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSALERT, lParam) ;
  330. break ;
  331. case IDM_VIEWLOG:
  332. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSLOG, lParam) ;
  333. break ;
  334. case IDM_VIEWREPORT:
  335. SendMessage (hWnd, WM_COMMAND, IDM_OPTIONSREPORT, lParam) ;
  336. break ;
  337. }
  338. break ;
  339. //=============================//
  340. // "File" Commands //
  341. //=============================//
  342. case IDM_FILENEWCHART:
  343. // if (QuerySaveChart (hWnd, pGraphs))
  344. ResetGraphView (hWndGraph) ;
  345. break ;
  346. case IDM_FILENEWALERT:
  347. // if (QuerySaveAlert (hWnd, hWndAlert))
  348. ResetAlertView (hWndAlert) ;
  349. break ;
  350. case IDM_FILENEWLOG:
  351. ResetLogView (hWndLog) ;
  352. break ;
  353. case IDM_FILENEWREPORT:
  354. ResetReportView (hWndReport) ;
  355. break ;
  356. case IDM_FILEOPENCHART:
  357. FileOpen (hWndGraph, IDS_CHARTFILE, NULL) ;
  358. break ;
  359. case IDM_FILEOPENALERT:
  360. FileOpen (hWndAlert, IDS_ALERTFILE, NULL) ;
  361. break ;
  362. case IDM_FILEOPENLOG:
  363. FileOpen (hWndLog, IDS_LOGFILE, NULL) ;
  364. break ;
  365. case IDM_FILEOPENREPORT:
  366. FileOpen (hWndReport, IDS_REPORTFILE, NULL) ;
  367. break ;
  368. case IDM_FILESAVECHART:
  369. case IDM_FILESAVEASCHART:
  370. bPrepareMenu = FALSE ;
  371. SaveChart (hWndGraph, 0,
  372. (LOWORD (wParam) == IDM_FILESAVEASCHART) ? TRUE : FALSE) ;
  373. break;
  374. case IDM_FILESAVEALERT:
  375. case IDM_FILESAVEASALERT:
  376. bPrepareMenu = FALSE ;
  377. SaveAlert (hWndAlert, 0,
  378. (LOWORD (wParam) == IDM_FILESAVEASALERT) ? TRUE : FALSE) ;
  379. break ;
  380. case IDM_FILESAVELOG:
  381. case IDM_FILESAVEASLOG:
  382. bPrepareMenu = FALSE ;
  383. SaveLog (hWndLog, 0,
  384. (LOWORD (wParam) == IDM_FILESAVEASLOG) ? TRUE : FALSE) ;
  385. break ;
  386. case IDM_FILESAVEREPORT:
  387. case IDM_FILESAVEASREPORT:
  388. bPrepareMenu = FALSE ;
  389. SaveReport (hWndReport, 0,
  390. (LOWORD (wParam) == IDM_FILESAVEASREPORT) ? TRUE : FALSE) ;
  391. break ;
  392. case IDM_FILESAVEWORKSPACE:
  393. bPrepareMenu = FALSE ;
  394. SaveWorkspace () ;
  395. break ;
  396. case IDM_FILEEXPORTCHART:
  397. bPrepareMenu = FALSE ;
  398. ExportChart () ;
  399. break ;
  400. case IDM_FILEEXPORTALERT:
  401. bPrepareMenu = FALSE ;
  402. ExportAlert () ;
  403. break ;
  404. case IDM_FILEEXPORTLOG:
  405. bPrepareMenu = FALSE ;
  406. ExportLog () ;
  407. break ;
  408. case IDM_FILEEXPORTREPORT:
  409. bPrepareMenu = FALSE ;
  410. ExportReport () ;
  411. break ;
  412. #ifdef KEEP_PRINT
  413. case IDM_FILEPRINTCHART:
  414. PrintChart (hWnd, pGraphs) ;
  415. break ;
  416. case IDM_FILEPRINTREPORT:
  417. PrintReport (hWnd, hWndReport) ;
  418. break ;
  419. #endif
  420. case IDM_FILEEXIT:
  421. PerfmonClose (hWnd) ;
  422. bPrepareMenu = FALSE ;
  423. break ;
  424. //=============================//
  425. // "Edit" Commands //
  426. //=============================//
  427. case IDM_EDITADDCHART:
  428. AddChart (hWnd) ;
  429. break;
  430. case IDM_EDITADDALERT:
  431. AddAlert (hWnd) ;
  432. break;
  433. case IDM_EDITADDLOG:
  434. AddLog (hWnd) ;
  435. break ;
  436. case IDM_EDITADDREPORT:
  437. AddReport (hWnd) ;
  438. break ;
  439. case IDM_EDITCLEARCHART :
  440. ClearGraphDisplay (pGraphs) ;
  441. break ;
  442. case IDM_EDITCLEARALERT:
  443. ClearAlertDisplay (hWndAlert) ;
  444. break ;
  445. case IDM_EDITCLEARREPORT:
  446. ClearReportDisplay (hWndReport) ;
  447. break ;
  448. case IDM_EDITDELETECHART:
  449. pLine = CurrentGraphLine (hWndGraph) ;
  450. if (pLine)
  451. ChartDeleteLine(pGraphs, pLine) ;
  452. break ;
  453. case IDM_EDITDELETEALERT:
  454. pLine = CurrentAlertLine (hWndAlert) ;
  455. if (pLine)
  456. AlertDeleteLine (hWndAlert, pLine) ;
  457. break ;
  458. case IDM_EDITDELETELOG:
  459. LogDeleteEntry (hWndLog) ;
  460. break ;
  461. case IDM_EDITDELETEREPORT:
  462. if (CurrentReportItem (hWndReport))
  463. ReportDeleteItem (hWndReport) ;
  464. break ;
  465. case IDM_EDITMODIFYCHART:
  466. EditChart (hWnd) ;
  467. break ;
  468. case IDM_EDITMODIFYALERT:
  469. EditAlert (hWnd) ;
  470. break ;
  471. case IDM_EDITTIMEWINDOW:
  472. if (PlayingBackLog()) {
  473. SetTimeframe (hWnd) ;
  474. }
  475. break ;
  476. //=============================//
  477. // "View" Commands //
  478. //=============================//
  479. case IDM_VIEWCHART:
  480. if (iPerfmonView != IDM_VIEWCHART) {
  481. ViewChart (hWnd) ;
  482. } else {
  483. bPrepareMenu = FALSE ;
  484. ToolbarDepressButton (hWndToolbar, ChartTool, TRUE) ;
  485. }
  486. break ;
  487. case IDM_VIEWALERT:
  488. if (iPerfmonView != IDM_VIEWALERT) {
  489. ViewAlert (hWnd) ;
  490. } else {
  491. bPrepareMenu = FALSE ;
  492. ToolbarDepressButton (hWndToolbar, AlertTool, TRUE) ;
  493. }
  494. break ;
  495. case IDM_VIEWLOG:
  496. if (iPerfmonView != IDM_VIEWLOG) {
  497. ViewLog (hWnd) ;
  498. } else {
  499. bPrepareMenu = FALSE ;
  500. ToolbarDepressButton (hWndToolbar, LogTool, TRUE) ;
  501. }
  502. break ;
  503. case IDM_VIEWREPORT:
  504. if (iPerfmonView != IDM_VIEWREPORT) {
  505. ViewReport (hWnd) ;
  506. } else {
  507. bPrepareMenu = FALSE ;
  508. ToolbarDepressButton (hWndToolbar, ReportTool, TRUE) ;
  509. }
  510. break ;
  511. //=============================//
  512. // "Options" Commands //
  513. //=============================//
  514. case IDM_OPTIONSCHART:
  515. DialogBox(hInstance, idDlgChartOptions, hWnd, GraphOptionDlg);
  516. break;
  517. case IDM_OPTIONSALERT:
  518. DisplayAlertOptions (hWnd, hWndAlert) ;
  519. break;
  520. case IDM_OPTIONSLOG:
  521. DisplayLogOptions (hWnd, hWndLog) ;
  522. break ;
  523. case IDM_OPTIONSREPORT:
  524. if (!PlayingBackLog())
  525. DisplayReportOptions (hWnd, hWndReport) ;
  526. break ;
  527. case IDM_OPTIONSBOOKMARK:
  528. bPrepareMenu = FALSE ;
  529. AddBookmark (hWnd) ;
  530. break;
  531. #ifdef KEEP_DISPLAY_OPTION
  532. case IDM_OPTIONSDISPLAY:
  533. DisplayDisplayOptions (hWnd) ;
  534. break ;
  535. #endif
  536. case IDM_OPTIONSDISPLAYMENU:
  537. // ShowPerfmonMenu will update Options.bMenubar..
  538. ShowPerfmonMenu (!Options.bMenubar) ;
  539. break ;
  540. case IDM_OPTIONSDISPLAYTOOL:
  541. Options.bToolbar = !Options.bToolbar ;
  542. SizePerfmonComponents () ;
  543. break ;
  544. case IDM_OPTIONSDISPLAYSTATUS:
  545. Options.bStatusbar = !Options.bStatusbar ;
  546. SizePerfmonComponents () ;
  547. break ;
  548. case IDM_OPTIONSDISPLAYONTOP:
  549. Options.bAlwaysOnTop = !Options.bAlwaysOnTop ;
  550. WindowSetTopmost (hWndMain, Options.bAlwaysOnTop) ;
  551. break ;
  552. case IDM_OPTIONSDATASOURCE:
  553. DisplayDataSourceOptions (hWnd) ;
  554. break ;
  555. #ifdef KEEP_MANUALREFRESH
  556. case IDM_OPTIONSMANUALREFRESH:
  557. bPrepareMenu = FALSE ;
  558. if (!PlayingBackLog())
  559. ToggleRefresh (hWnd) ;
  560. break ;
  561. #endif
  562. case IDM_OPTIONSREFRESHNOWCHART:
  563. bPrepareMenu = FALSE ;
  564. if (!PlayingBackLog())
  565. GraphTimer (hWndGraph, TRUE) ;
  566. break ;
  567. case IDM_OPTIONSREFRESHNOWALERT:
  568. bPrepareMenu = FALSE ;
  569. if (!PlayingBackLog())
  570. AlertTimer (hWndAlert, TRUE) ;
  571. break ;
  572. case IDM_OPTIONSREFRESHNOWLOG:
  573. bPrepareMenu = FALSE ;
  574. if (!PlayingBackLog())
  575. LogTimer (hWndLog, TRUE) ;
  576. break ;
  577. case IDM_OPTIONSREFRESHNOWREPORT:
  578. bPrepareMenu = FALSE ;
  579. if (!PlayingBackLog())
  580. ReportTimer (hWndReport, TRUE) ;
  581. break ;
  582. case IDM_OPTIONSLEGENDONOFF:
  583. bPrepareMenu = FALSE ;
  584. if (iPerfmonView == IDM_VIEWCHART) {
  585. pGraphs->gOptions.bLegendChecked =
  586. !pGraphs->gOptions.bLegendChecked ;
  587. SizeGraphComponents (hWndGraph) ;
  588. WindowInvalidate (hWndGraph) ;
  589. } else if (iPerfmonView == IDM_VIEWALERT) {
  590. PALERT pAlert = AlertData (hWnd) ;
  591. pAlert->bLegendOn = !pAlert->bLegendOn ;
  592. SizeAlertComponents (hWndAlert) ;
  593. WindowInvalidate (hWndAlert) ;
  594. }
  595. break ;
  596. //=============================//
  597. // "Help" Commands //
  598. //=============================//
  599. case IDM_HELPABOUT:
  600. {
  601. TCHAR szApplication [WindowCaptionLen] ;
  602. bPrepareMenu = FALSE ;
  603. if (GetKeyState(VK_SHIFT) < 0 && GetKeyState(VK_CONTROL) < 0) {
  604. DialogBox (hInstance, idDlgAbout, hWndMain, AboutDlgProc) ;
  605. } else {
  606. StringLoad (IDS_APPNAME, szApplication) ;
  607. ShellAbout (hWnd, szApplication, NULL, hIcon) ;
  608. }
  609. }
  610. break ;
  611. //======================================//
  612. // Generic messages from ACCELERATORS //
  613. //======================================//
  614. case IDM_FILEOPENFILE:
  615. bPrepareMenu = FALSE ;
  616. switch (iPerfmonView) {
  617. case IDM_VIEWCHART:
  618. SendMessage (hWnd, WM_COMMAND, IDM_FILEOPENCHART, lParam) ;
  619. break ;
  620. case IDM_VIEWALERT:
  621. SendMessage (hWnd, WM_COMMAND, IDM_FILEOPENALERT, lParam) ;
  622. break ;
  623. case IDM_VIEWLOG:
  624. SendMessage (hWnd, WM_COMMAND, IDM_FILEOPENLOG, lParam) ;
  625. break ;
  626. case IDM_VIEWREPORT:
  627. SendMessage (hWnd, WM_COMMAND, IDM_FILEOPENREPORT, lParam) ;
  628. break ;
  629. }
  630. break ;
  631. case IDM_FILESAVEFILE:
  632. bPrepareMenu = FALSE ;
  633. switch (iPerfmonView) {
  634. case IDM_VIEWCHART:
  635. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVECHART, lParam) ;
  636. break ;
  637. case IDM_VIEWALERT:
  638. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEALERT, lParam) ;
  639. break ;
  640. case IDM_VIEWLOG:
  641. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVELOG, lParam) ;
  642. break ;
  643. case IDM_VIEWREPORT:
  644. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEREPORT, lParam) ;
  645. break ;
  646. }
  647. break ;
  648. case IDM_FILESAVEASFILE:
  649. bPrepareMenu = FALSE ;
  650. switch (iPerfmonView) {
  651. case IDM_VIEWCHART:
  652. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEASCHART, lParam) ;
  653. break ;
  654. case IDM_VIEWALERT:
  655. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEASALERT, lParam) ;
  656. break ;
  657. case IDM_VIEWLOG:
  658. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEASLOG, lParam) ;
  659. break ;
  660. case IDM_VIEWREPORT:
  661. SendMessage (hWnd, WM_COMMAND, IDM_FILESAVEASREPORT, lParam) ;
  662. break ;
  663. }
  664. break ;
  665. case IDM_CHARTHIGHLIGHTON:
  666. bPrepareMenu = FALSE ;
  667. if (iPerfmonView == IDM_VIEWCHART) {
  668. ChartHighlight () ;
  669. }
  670. break ;
  671. case IDM_TOOLBARID:
  672. // msg from the toolbar control
  673. bPrepareMenu = FALSE ;
  674. OnToolbarHit (wParam, lParam) ;
  675. break ;
  676. case IDM_HELPCONTENTS:
  677. {
  678. TCHAR NullStr [2] ;
  679. NullStr[0] = TEXT('\0') ;
  680. bPrepareMenu = FALSE ;
  681. if (*pszHelpFile != 0) {
  682. WinHelp (hWndMain, pszHelpFile, HELP_FINDER, (DWORD_PTR)(NullStr)) ;
  683. } else {
  684. DlgErrorBox (hWnd, ERR_HELP_NOT_AVAILABLE);
  685. }
  686. }
  687. break ;
  688. case IDM_HELPSEARCH:
  689. {
  690. TCHAR NullStr [2] ;
  691. NullStr[0] = TEXT('\0') ;
  692. bPrepareMenu = FALSE ;
  693. if (*pszHelpFile != 0) {
  694. WinHelp (hWndMain, pszHelpFile, HELP_PARTIALKEY, (DWORD_PTR)(NullStr)) ;
  695. } else {
  696. DlgErrorBox (hWnd, ERR_HELP_NOT_AVAILABLE);
  697. }
  698. }
  699. break ;
  700. case IDM_HELPHELP:
  701. {
  702. TCHAR NullStr [2] ;
  703. NullStr[0] = TEXT('\0') ;
  704. bPrepareMenu = FALSE ;
  705. if (*pszHelpFile != 0) {
  706. WinHelp (hWndMain, pszHelpFile, HELP_HELPONHELP, (DWORD_PTR)(NullStr)) ;
  707. } else {
  708. DlgErrorBox (hWnd, ERR_HELP_NOT_AVAILABLE);
  709. }
  710. }
  711. break ;
  712. default:
  713. return (FALSE) ;
  714. }
  715. if (bPrepareMenu) {
  716. PrepareMenu (GetMenu (hWnd)) ;
  717. }
  718. return (TRUE) ;
  719. }
  720. void
  721. PrepareMenu (
  722. HMENU hMenu
  723. )
  724. {
  725. BOOL bPlayingLog ;
  726. BOOL bCurrentLine = FALSE;
  727. BOOL bManualRefresh = FALSE;
  728. BOOL bLogCollecting ;
  729. BOOL bRefresh ;
  730. // hMenu is NULL when the menu bar display option is off.
  731. // In that case, we still have to enable/disable all tool buttons
  732. // So, I have commented out the next 2 lines...
  733. // if (!hMenu)
  734. // return ;
  735. bLogCollecting = LogCollecting (hWndLog) ;
  736. bPlayingLog = PlayingBackLog () ;
  737. switch (iPerfmonView) {
  738. case IDM_VIEWCHART:
  739. bCurrentLine = (CurrentGraphLine (hWndGraph) != NULL) ;
  740. bRefresh = GraphRefresh (hWndGraph) ;
  741. bManualRefresh = !bPlayingLog && bCurrentLine ;
  742. if (hMenu) {
  743. MenuCheck (hMenu, IDM_VIEWCHART, TRUE) ;
  744. MenuEnableItem (hMenu, IDM_FILEEXPORTCHART, bCurrentLine) ;
  745. MenuEnableItem (hMenu, IDM_EDITMODIFYCHART, bCurrentLine) ;
  746. MenuEnableItem (hMenu, IDM_EDITDELETECHART, bCurrentLine) ;
  747. MenuEnableItem (hMenu, IDM_OPTIONSREFRESHNOWCHART, bManualRefresh) ;
  748. MenuEnableItem (hMenu, IDM_EDITCLEARCHART, !bPlayingLog && bCurrentLine) ;
  749. }
  750. break ;
  751. case IDM_VIEWALERT:
  752. bCurrentLine = (CurrentAlertLine (hWndAlert) != NULL) ;
  753. bRefresh = AlertRefresh (hWndAlert) ;
  754. bManualRefresh = !bPlayingLog && bCurrentLine ;
  755. if (hMenu) {
  756. MenuCheck (hMenu, IDM_VIEWALERT, TRUE) ;
  757. MenuEnableItem (hMenu, IDM_FILEEXPORTALERT, bCurrentLine) ;
  758. MenuEnableItem (hMenu, IDM_EDITMODIFYALERT, bCurrentLine) ;
  759. MenuEnableItem (hMenu, IDM_EDITDELETEALERT, bCurrentLine) ;
  760. MenuEnableItem (hMenu, IDM_EDITCLEARALERT, !bPlayingLog && bCurrentLine) ;
  761. MenuEnableItem (hMenu, IDM_OPTIONSREFRESHNOWALERT, bManualRefresh) ;
  762. }
  763. break ;
  764. case IDM_VIEWLOG:
  765. bCurrentLine = AnyLogLine() ;
  766. bRefresh = LogRefresh (hWndLog) ;
  767. bManualRefresh = !bPlayingLog && bLogCollecting ;
  768. if (hMenu) {
  769. MenuCheck (hMenu, IDM_VIEWLOG, TRUE) ;
  770. MenuEnableItem (hMenu, IDM_FILEEXPORTLOG, bCurrentLine) ;
  771. MenuEnableItem (hMenu, IDM_EDITDELETELOG, bCurrentLine) ;
  772. MenuEnableItem (hMenu, IDM_OPTIONSREFRESHNOWLOG , bManualRefresh) ;
  773. }
  774. break ;
  775. case IDM_VIEWREPORT:
  776. bCurrentLine = CurrentReportItem (hWndReport) ;
  777. bRefresh = ReportRefresh (hWndReport) ;
  778. bManualRefresh = !bPlayingLog && bCurrentLine ;
  779. if (hMenu) {
  780. MenuCheck (hMenu, IDM_VIEWREPORT, TRUE) ;
  781. MenuEnableItem (hMenu, IDM_FILEEXPORTREPORT, bCurrentLine) ;
  782. MenuEnableItem (hMenu, IDM_EDITMODIFYREPORT, FALSE) ;
  783. MenuEnableItem (hMenu, IDM_EDITDELETEREPORT, bCurrentLine) ;
  784. MenuEnableItem (hMenu, IDM_EDITCLEARREPORT, !bPlayingLog && bCurrentLine) ;
  785. MenuEnableItem (hMenu, IDM_OPTIONSREFRESHNOWREPORT, bManualRefresh) ;
  786. }
  787. break ;
  788. }
  789. ToolbarEnableButton (hWndToolbar, EditTool,
  790. bCurrentLine &&
  791. (iPerfmonView != IDM_VIEWREPORT &&
  792. iPerfmonView != IDM_VIEWLOG)) ;
  793. ToolbarEnableButton (hWndToolbar, DeleteTool, bCurrentLine) ;
  794. ToolbarEnableButton (hWndToolbar, RefreshTool, bManualRefresh) ;
  795. // None of the alert or report options make sense when playing back a log.
  796. #if 0
  797. ToolbarEnableButton (hWndToolbar,
  798. OptionsTool,
  799. !bPlayingLog ||
  800. (iPerfmonView != IDM_VIEWREPORT &&
  801. iPerfmonView != IDM_VIEWALERT)) ;
  802. #endif
  803. ToolbarEnableButton (hWndToolbar,
  804. OptionsTool,
  805. !bPlayingLog ||
  806. iPerfmonView != IDM_VIEWREPORT) ;
  807. ToolbarEnableButton (hWndToolbar, BookmarkTool, bLogCollecting) ;
  808. if (hMenu) {
  809. // MenuEnableItem (hMenu, IDM_OPTIONSMANUALREFRESH, !bPlayingLog) ;
  810. // MenuCheck (hMenu, IDM_OPTIONSMANUALREFRESH, bRefresh) ;
  811. MenuEnableItem (hMenu, IDM_EDITTIMEWINDOW, bPlayingLog) ;
  812. // MenuEnableItem (hMenu, IDM_OPTIONSALERT, !bPlayingLog) ;
  813. MenuEnableItem (hMenu, IDM_OPTIONSREPORT, !bPlayingLog) ;
  814. MenuEnableItem (hMenu, IDM_OPTIONSBOOKMARK, bLogCollecting) ;
  815. // check/uncheck all the display options
  816. MenuCheck (hMenu, IDM_OPTIONSDISPLAYMENU, Options.bMenubar) ;
  817. MenuCheck (hMenu, IDM_OPTIONSDISPLAYTOOL, Options.bToolbar) ;
  818. MenuCheck (hMenu, IDM_OPTIONSDISPLAYSTATUS, Options.bStatusbar) ;
  819. MenuCheck (hMenu, IDM_OPTIONSDISPLAYONTOP, Options.bAlwaysOnTop) ;
  820. }
  821. }