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