|
|
1.1 ! root 1: /***************************************************************************** ! 2: * ! 3: * Dialogs.c - This module handles the Menu and Dialog user interactions. ! 4: * ! 5: * Microsoft Confidential ! 6: * Copyright (c) 1992-1993 Microsoft Corporation ! 7: * ! 8: ****************************************************************************/ ! 9: ! 10: #include <stdio.h> ! 11: ! 12: #include "perfmon.h" ! 13: ! 14: #include "alert.h" // for SetAlertTimer, AlertData ! 15: #include "graph.h" ! 16: #include "cderr.h" ! 17: #include "utils.h" ! 18: #include "playback.h" // for PlayingBackLog ! 19: #include "grafdisp.h" // for ToggleGraphRefresh ! 20: #include "pmhelpid.h" // Help IDs ! 21: ! 22: ! 23: static BOOL LocalManualRefresh ; ! 24: ! 25: ! 26: /***************************************************************************/ ! 27: BOOL FAR PASCAL GraphOptionDlg(HWND hDlg, WORD msg, DWORD wParam, LONG lParam) ! 28: /***************************************************************************/ ! 29: { ! 30: static GRAPH_OPTIONS goLocalCopy ; ! 31: ! 32: INT iTimeMilliseconds ; ! 33: TCHAR szBuff[MiscTextLen] ; ! 34: PGRAPHSTRUCT lgraph; ! 35: ! 36: lParam ; ! 37: lgraph = pGraphs; ! 38: ! 39: switch(msg) ! 40: { ! 41: ! 42: case WM_INITDIALOG: ! 43: ! 44: dwCurrentDlgID = HC_PM_idDlgOptionChart ; ! 45: ! 46: // Init the Radio button, Check boxes and text fields. ! 47: ! 48: goLocalCopy.iGraphOrHistogram = ! 49: lgraph->gOptions.iGraphOrHistogram ; ! 50: if (lgraph->gOptions.iGraphOrHistogram == LINE_GRAPH) ! 51: CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_GRAPH) ; ! 52: else ! 53: CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ID_HISTOGRAM) ; ! 54: ! 55: CheckDlgButton(hDlg, ID_LEGEND, lgraph->gOptions.bLegendChecked) ; ! 56: if (!(lgraph->gOptions.bLegendChecked)) ! 57: { ! 58: // can't display valuebar w/o legend ! 59: DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, FALSE) ; ! 60: } ! 61: ! 62: CheckDlgButton(hDlg, ID_LABELS, lgraph->gOptions.bLabelsChecked) ; ! 63: CheckDlgButton(hDlg, ID_VERT_GRID, lgraph->gOptions.bVertGridChecked) ; ! 64: CheckDlgButton(hDlg, ID_HORZ_GRID, lgraph->gOptions.bHorzGridChecked) ; ! 65: CheckDlgButton(hDlg, IDD_CHARTOPTIONSVALUEBAR, ! 66: lgraph->gOptions.bStatusBarChecked) ; ! 67: ! 68: TSPRINTF(szBuff, TEXT("%d"), lgraph->gOptions.iVertMax) ; ! 69: SendDlgItemMessage(hDlg, ID_VERT_MAX, WM_SETTEXT, 0, (LONG) szBuff) ; ! 70: ! 71: TSPRINTF(szBuff, TEXT("%3.3f"), lgraph->gOptions.eTimeInterval) ; ! 72: SendDlgItemMessage(hDlg, IDD_CHARTOPTIONSINTERVAL, WM_SETTEXT, 0, (LONG) szBuff) ; ! 73: ! 74: // Pickup a local copy of the Graph Options. ! 75: ! 76: goLocalCopy = lgraph->gOptions ; ! 77: LocalManualRefresh = lgraph->bManualRefresh ; ! 78: ! 79: if (PlayingBackLog()) ! 80: { ! 81: DialogEnable (hDlg, IDD_CHARTOPTIONSPERIODIC, FALSE) ; ! 82: DialogEnable (hDlg, IDD_CHARTOPTIONSUPDATETEXT, FALSE) ; ! 83: DialogEnable (hDlg, IDD_CHARTOPTIONSMANUALREFRESH, FALSE) ; ! 84: } ! 85: else ! 86: { ! 87: CheckRadioButton (hDlg, ! 88: IDD_CHARTOPTIONSMANUALREFRESH, ! 89: IDD_CHARTOPTIONSPERIODIC, ! 90: LocalManualRefresh ? IDD_CHARTOPTIONSMANUALREFRESH : ! 91: IDD_CHARTOPTIONSPERIODIC) ; ! 92: } ! 93: ! 94: if (lgraph->bManualRefresh || PlayingBackLog()) ! 95: { ! 96: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, FALSE) ; ! 97: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, FALSE) ; ! 98: } ! 99: else ! 100: { ! 101: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, TRUE) ; ! 102: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, TRUE) ; ! 103: } ! 104: ! 105: EditSetLimit (GetDlgItem(hDlg, ID_VERT_MAX), ! 106: sizeof(szBuff) / sizeof(TCHAR) - 1) ; ! 107: ! 108: EditSetLimit (GetDlgItem(hDlg, IDD_CHARTOPTIONSINTERVAL), ! 109: ShortTextLen) ; ! 110: ! 111: WindowCenter (hDlg) ; ! 112: return(TRUE); ! 113: ! 114: case WM_COMMAND: ! 115: switch(LOWORD(wParam)) ! 116: { ! 117: case ID_VERT_MAX: ! 118: if (HIWORD(wParam) == EN_CHANGE) ! 119: { ! 120: DialogText(hDlg, ID_VERT_MAX, szBuff) ; ! 121: swscanf(szBuff, TEXT("%d"), &goLocalCopy.iVertMax) ; ! 122: } ! 123: break ; ! 124: ! 125: ! 126: case IDD_CHARTOPTIONSINTERVAL: ! 127: if (HIWORD(wParam) == EN_CHANGE) ! 128: { ! 129: goLocalCopy.eTimeInterval = ! 130: DialogFloat (hDlg, IDD_CHARTOPTIONSINTERVAL, NULL) ; ! 131: } ! 132: break ; ! 133: ! 134: case IDD_CHARTOPTIONSPERIODIC: ! 135: case IDD_CHARTOPTIONSMANUALREFRESH: ! 136: // check if the Manual refresh is currently checked. ! 137: // Then toggle the ManualRefresh button ! 138: LocalManualRefresh = ! 139: IsDlgButtonChecked (hDlg, IDD_CHARTOPTIONSMANUALREFRESH) ; ! 140: CheckRadioButton (hDlg, ! 141: IDD_CHARTOPTIONSMANUALREFRESH, ! 142: IDD_CHARTOPTIONSPERIODIC, ! 143: LocalManualRefresh ? IDD_CHARTOPTIONSPERIODIC : ! 144: IDD_CHARTOPTIONSMANUALREFRESH) ; ! 145: ! 146: // gray out time interval if necessary... ! 147: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVALTEXT, ! 148: LocalManualRefresh) ; ! 149: DialogEnable (hDlg, IDD_CHARTOPTIONSINTERVAL, ! 150: LocalManualRefresh) ; ! 151: LocalManualRefresh = !LocalManualRefresh ; ! 152: break ; ! 153: ! 154: case IDD_CHARTOPTIONSVALUEBAR: ! 155: if (goLocalCopy.bStatusBarChecked == TRUE) ! 156: goLocalCopy.bStatusBarChecked = FALSE ; ! 157: else ! 158: goLocalCopy.bStatusBarChecked = TRUE ; ! 159: break ; ! 160: ! 161: ! 162: case ID_LEGEND: ! 163: if (goLocalCopy.bLegendChecked == TRUE) ! 164: goLocalCopy.bLegendChecked = FALSE ; ! 165: else ! 166: goLocalCopy.bLegendChecked = TRUE ; ! 167: ! 168: DialogEnable (hDlg, IDD_CHARTOPTIONSVALUEBAR, ! 169: goLocalCopy.bLegendChecked) ; ! 170: ! 171: break ; ! 172: ! 173: ! 174: case ID_LABELS: ! 175: if (goLocalCopy.bLabelsChecked == TRUE) ! 176: goLocalCopy.bLabelsChecked = FALSE ; ! 177: else ! 178: goLocalCopy.bLabelsChecked = TRUE ; ! 179: break ; ! 180: ! 181: ! 182: case ID_VERT_GRID: ! 183: if (goLocalCopy.bVertGridChecked == TRUE) ! 184: goLocalCopy.bVertGridChecked = FALSE ; ! 185: else ! 186: goLocalCopy.bVertGridChecked = TRUE ; ! 187: break ; ! 188: ! 189: ! 190: case ID_HORZ_GRID: ! 191: if (goLocalCopy.bHorzGridChecked == TRUE) ! 192: goLocalCopy.bHorzGridChecked = FALSE ; ! 193: else ! 194: goLocalCopy.bHorzGridChecked = TRUE ; ! 195: break ; ! 196: ! 197: ! 198: case ID_GRAPH: ! 199: case ID_HISTOGRAM: ! 200: if (goLocalCopy.iGraphOrHistogram == BAR_GRAPH) ! 201: { ! 202: goLocalCopy.iGraphOrHistogram = LINE_GRAPH ; ! 203: } ! 204: else ! 205: { ! 206: goLocalCopy.iGraphOrHistogram = BAR_GRAPH ; ! 207: } ! 208: CheckRadioButton(hDlg, ID_GRAPH, ID_HISTOGRAM, ! 209: goLocalCopy.iGraphOrHistogram == LINE_GRAPH ? ! 210: ID_GRAPH : ID_HISTOGRAM) ; ! 211: ! 212: break ; ! 213: ! 214: case IDOK: ! 215: // verify some numeric entries first ! 216: if (goLocalCopy.iVertMax > MAX_VERTICAL || ! 217: goLocalCopy.iVertMax < MIN_VERTICAL) ! 218: { ! 219: DlgErrorBox (hDlg, ERR_BADVERTMAX) ; ! 220: SetFocus (DialogControl (hDlg, ID_VERT_MAX)) ; ! 221: EditSetTextEndPos (hDlg, ID_VERT_MAX) ; ! 222: return (FALSE) ; ! 223: break ; ! 224: } ! 225: if (goLocalCopy.eTimeInterval > MAX_INTERVALSEC || ! 226: goLocalCopy.eTimeInterval < MIN_INTERVALSEC) ! 227: { ! 228: DlgErrorBox (hDlg, ERR_BADTIMEINTERVAL) ; ! 229: SetFocus (DialogControl (hDlg, IDD_CHARTOPTIONSINTERVAL)) ; ! 230: EditSetTextEndPos (hDlg, IDD_CHARTOPTIONSINTERVAL) ; ! 231: return (FALSE) ; ! 232: break ; ! 233: } ! 234: ! 235: // We need to send a size message to the main window ! 236: // so it can setup the redraw of the graph and legend. ! 237: ! 238: lgraph->gOptions.bLegendChecked = goLocalCopy.bLegendChecked ; ! 239: lgraph->gOptions.bStatusBarChecked = goLocalCopy.bStatusBarChecked ; ! 240: ! 241: if (lgraph->gOptions.eTimeInterval != goLocalCopy.eTimeInterval ! 242: && !LocalManualRefresh) ! 243: { ! 244: iTimeMilliseconds = (INT) (goLocalCopy.eTimeInterval * (FLOAT) 1000.0) ; ! 245: pGraphs->gInterval = iTimeMilliseconds ; ! 246: if (!PlayingBackLog()) ! 247: { ! 248: SetGraphTimer(pGraphs) ; ! 249: } ! 250: lgraph->bManualRefresh = LocalManualRefresh ; ! 251: ! 252: } ! 253: else if (LocalManualRefresh != lgraph->bManualRefresh) ! 254: { ! 255: ToggleGraphRefresh (hWndGraph) ; ! 256: } ! 257: // Assign the local copy of the graph options to the ! 258: // global copy. ! 259: ! 260: lgraph->gOptions = goLocalCopy ; ! 261: ! 262: SizeGraphComponents (hWndGraph) ; ! 263: WindowInvalidate (hWndGraph) ; ! 264: dwCurrentDlgID = 0 ; ! 265: EndDialog (hDlg, 1) ; ! 266: return (TRUE) ; ! 267: break ; ! 268: ! 269: ! 270: case IDCANCEL: ! 271: dwCurrentDlgID = 0 ; ! 272: EndDialog(hDlg,0); ! 273: return(TRUE); ! 274: ! 275: case ID_HELP: ! 276: CallWinHelp (dwCurrentDlgID) ; ! 277: break ; ! 278: ! 279: default: ! 280: break; ! 281: } ! 282: break; ! 283: ! 284: default: ! 285: break; ! 286: ! 287: } ! 288: return(FALSE); ! 289: } ! 290: ! 291: ! 292: ! 293: ! 294: DWORD iIntervalMSecs ; ! 295: BOOL bSwitchToAlert ; ! 296: BOOL bNetworkAlert ; ! 297: ! 298: ! 299: void static OnAlertOptionDlgInit (HWND hDlg, PALERT pAlert) ! 300: { ! 301: BOOL EnableFlag ; ! 302: ! 303: iIntervalMSecs = pAlert->iIntervalMSecs ; ! 304: bNetworkAlert = pAlert->bNetworkAlert ; ! 305: bSwitchToAlert = pAlert->bSwitchToAlert ; ! 306: ! 307: LocalManualRefresh = pAlert->bManualRefresh ; ! 308: ! 309: if (PlayingBackLog()) ! 310: { ! 311: // When playingback log, disable all controls except ! 312: // the alert interval ! 313: // ! 314: EnableFlag = TRUE ; ! 315: DialogEnable (hDlg, IDD_ALERTOPTIONSMANUALREFRESH, FALSE) ; ! 316: DialogEnable (hDlg, IDD_ALERTOPTIONSPOPUP, FALSE) ; ! 317: DialogEnable (hDlg, IDD_ALERTOPTIONSNETWORKALERT, FALSE) ; ! 318: DialogEnable (hDlg, IDD_ALERTOPTIONSNETGROUPTEXT, FALSE) ; ! 319: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAME, FALSE) ; ! 320: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAMETEXT, FALSE) ; ! 321: } ! 322: else ! 323: { ! 324: EnableFlag = !LocalManualRefresh ; ! 325: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAME, pAlert->bNetworkAlert) ; ! 326: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAMETEXT, pAlert->bNetworkAlert) ; ! 327: } ! 328: ! 329: // setup the Update time interval group items ! 330: DialogSetInterval (hDlg, IDD_ALERTOPTIONSINTERVAL, iIntervalMSecs) ; ! 331: DialogEnable (hDlg, IDD_ALERTOPTIONSINTERVAL, EnableFlag) ; ! 332: DialogEnable (hDlg, IDD_ALERTOPTIONSINTERVALTEXT, EnableFlag) ; ! 333: CheckRadioButton(hDlg, IDD_ALERTOPTIONSMANUALREFRESH, ! 334: IDD_ALERTOPTIONSPERIODIC, ! 335: !EnableFlag ? IDD_ALERTOPTIONSMANUALREFRESH : IDD_ALERTOPTIONSPERIODIC) ; ! 336: ! 337: CheckDlgButton (hDlg, IDD_ALERTOPTIONSPOPUP, pAlert->bSwitchToAlert) ; ! 338: CheckDlgButton (hDlg, IDD_ALERTOPTIONSNETWORKALERT, pAlert->bNetworkAlert) ; ! 339: ! 340: if (pAlert->MessageName[0]) ! 341: { ! 342: DialogSetString (hDlg, IDD_ALERTOPTIONSMSGNAME, pAlert->MessageName) ; ! 343: } ! 344: ! 345: EditSetLimit (GetDlgItem(hDlg, IDD_ALERTOPTIONSMSGNAME), ! 346: sizeof(pAlert->MessageName)/sizeof(TCHAR) - 1) ; ! 347: ! 348: dwCurrentDlgID = HC_PM_idDlgOptionAlert ; ! 349: ! 350: WindowCenter (hDlg) ; ! 351: ! 352: } // OnAlertOptionDlgInit ! 353: ! 354: BOOL FAR PASCAL AlertOptionDlg (HWND hDlg, WORD msg, ! 355: DWORD wParam, LONG lParam) ! 356: { ! 357: ! 358: PALERT pAlert ; ! 359: ! 360: switch(msg) ! 361: { ! 362: ! 363: case WM_INITDIALOG: ! 364: pAlert = (PALERT) lParam ; ! 365: OnAlertOptionDlgInit (hDlg, pAlert) ; ! 366: return(TRUE); ! 367: ! 368: case WM_COMMAND: ! 369: switch(LOWORD(wParam)) ! 370: { ! 371: case IDOK: ! 372: { ! 373: FLOAT eTimeInterval ; ! 374: ! 375: pAlert = AlertData (hWndAlert) ; ! 376: ! 377: eTimeInterval = DialogFloat (hDlg, IDD_ALERTOPTIONSINTERVAL, NULL) ; ! 378: ! 379: if (eTimeInterval > MAX_INTERVALSEC || ! 380: eTimeInterval < MIN_INTERVALSEC) ! 381: { ! 382: DlgErrorBox (hDlg, ERR_BADTIMEINTERVAL) ; ! 383: SetFocus (DialogControl (hDlg, IDD_ALERTOPTIONSINTERVAL)) ; ! 384: EditSetTextEndPos (hDlg, IDD_ALERTOPTIONSINTERVAL) ; ! 385: return (FALSE) ; ! 386: break ; ! 387: } ! 388: ! 389: eTimeInterval = eTimeInterval * (FLOAT) 1000.0 + ! 390: (FLOAT) 0.5 ; ! 391: ! 392: iIntervalMSecs = (DWORD) eTimeInterval ; ! 393: ! 394: pAlert->bNetworkAlert = bNetworkAlert ; ! 395: pAlert->bSwitchToAlert = bSwitchToAlert ; ! 396: ! 397: ! 398: if (!PlayingBackLog()) ! 399: { ! 400: DialogText (hDlg, ! 401: IDD_ALERTOPTIONSMSGNAME, ! 402: pAlert->MessageName) ; ! 403: } ! 404: ! 405: dwCurrentDlgID = 0 ; ! 406: EndDialog (hDlg, 1) ; ! 407: } ! 408: break ; ! 409: ! 410: case IDCANCEL: ! 411: dwCurrentDlgID = 0 ; ! 412: EndDialog(hDlg,0); ! 413: return(TRUE); ! 414: ! 415: case IDD_ALERTOPTIONSPERIODIC: ! 416: case IDD_ALERTOPTIONSMANUALREFRESH: ! 417: ! 418: if (!PlayingBackLog()) ! 419: { ! 420: // check if the Manual refresh is currently checked. ! 421: // Then toggle the ManualRefresh button ! 422: LocalManualRefresh = ! 423: IsDlgButtonChecked (hDlg, IDD_ALERTOPTIONSMANUALREFRESH) ; ! 424: ! 425: CheckRadioButton(hDlg, ! 426: IDD_ALERTOPTIONSMANUALREFRESH, ! 427: IDD_ALERTOPTIONSPERIODIC, ! 428: LocalManualRefresh ? IDD_ALERTOPTIONSPERIODIC : ! 429: IDD_ALERTOPTIONSMANUALREFRESH) ; ! 430: ! 431: DialogEnable (hDlg, ! 432: IDD_ALERTOPTIONSINTERVAL, ! 433: LocalManualRefresh) ; ! 434: ! 435: DialogEnable (hDlg, ! 436: IDD_ALERTOPTIONSINTERVALTEXT, ! 437: LocalManualRefresh) ; ! 438: ! 439: LocalManualRefresh = !LocalManualRefresh ; ! 440: } ! 441: ! 442: break ; ! 443: ! 444: case IDD_ALERTOPTIONSPOPUP: ! 445: bSwitchToAlert = !bSwitchToAlert ; ! 446: CheckDlgButton (hDlg, IDD_ALERTOPTIONSPOPUP, bSwitchToAlert) ; ! 447: break; ! 448: ! 449: case IDD_ALERTOPTIONSNETWORKALERT: ! 450: bNetworkAlert = !bNetworkAlert ; ! 451: CheckDlgButton (hDlg, IDD_ALERTOPTIONSNETWORKALERT, bNetworkAlert) ; ! 452: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAME, bNetworkAlert) ; ! 453: DialogEnable (hDlg, IDD_ALERTOPTIONSMSGNAMETEXT, bNetworkAlert) ; ! 454: ! 455: if (bNetworkAlert) ! 456: { ! 457: SetFocus (GetDlgItem(hDlg, IDD_ALERTOPTIONSMSGNAME)) ; ! 458: SendDlgItemMessage(hDlg, IDD_ALERTOPTIONSMSGNAME, ! 459: EM_SETSEL, 0, 16) ; ! 460: } ! 461: ! 462: break; ! 463: ! 464: case IDD_DISPLAYHELP: ! 465: CallWinHelp (dwCurrentDlgID) ; ! 466: break ; ! 467: ! 468: default: ! 469: break; ! 470: } ! 471: break; ! 472: ! 473: ! 474: default: ! 475: break; ! 476: ! 477: } ! 478: ! 479: return (FALSE); ! 480: } // AlertOptionDlg ! 481: ! 482: ! 483: BOOL DisplayAlertOptions (HWND hWndParent, ! 484: HWND hWndAlert) ! 485: { // DisplayAlertOptions ! 486: PALERT pAlert ; ! 487: ! 488: pAlert = AlertData (hWndParent) ; ! 489: ! 490: if (DialogBoxParam (hInstance, idDlgAlertOptions, ! 491: hWndParent, (DLGPROC) AlertOptionDlg, ! 492: (LPARAM) pAlert)) ! 493: { // if ! 494: ! 495: if (PlayingBackLog()) ! 496: { ! 497: if (pAlert->iIntervalMSecs != iIntervalMSecs) ! 498: { ! 499: // a new time interval, re-do the backing back log ! 500: // using the new value... ! 501: pAlert->iIntervalMSecs = iIntervalMSecs ; ! 502: DialogSetInterval (hWndAlert, IDD_ALERTINTERVAL, iIntervalMSecs) ; ! 503: if (pAlert->pLineFirst) ! 504: { ! 505: PlaybackAlert (hWndAlert, 0) ; ! 506: WindowInvalidate (hWndAlert) ; ! 507: } ! 508: } ! 509: } ! 510: else if (LocalManualRefresh != pAlert->bManualRefresh) ! 511: { ! 512: if (!LocalManualRefresh) ! 513: { ! 514: pAlert->iIntervalMSecs = iIntervalMSecs ; ! 515: DialogSetInterval (hWndAlert, IDD_ALERTINTERVAL, iIntervalMSecs) ; ! 516: } ! 517: ToggleAlertRefresh (hWndAlert) ; ! 518: } ! 519: else if (!LocalManualRefresh) ! 520: { ! 521: pAlert->iIntervalMSecs = iIntervalMSecs ; ! 522: SetAlertTimer (pAlert) ; ! 523: DialogSetInterval (hWndAlert, IDD_ALERTINTERVAL, iIntervalMSecs) ; ! 524: } ! 525: } // if ! 526: ! 527: return (TRUE) ; ! 528: } // DisplayAlertOptions ! 529: ! 530:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.