Annotation of mstools/samples/sdktools/perfmon/addlog.c, revision 1.1.1.1

1.1       root        1: 
                      2: //==========================================================================//
                      3: //                                  Includes                                //
                      4: //==========================================================================//
                      5: 
                      6: #include "perfmon.h"
                      7: #include "utils.h"
                      8: #include "log.h"
                      9: #include "pmemory.h"    // for MemoryXXX (malloc-like) routines
                     10: #include "perfdata.h"
                     11: #include "perfmops.h"
                     12: #include "system.h"     // for SystemGet
                     13: #include "playback.h"   // for PlayingBackLog & DataFromIndexPosition
                     14: #include "pmhelpid.h"   // Help IDs
                     15: 
                     16: //==========================================================================//
                     17: //                               External Data                                //
                     18: //==========================================================================//
                     19: 
                     20: extern HWND          hWndLogEntries ;
                     21: 
                     22: BOOL                 ComputerChange ;
                     23: static   PPERFDATA   pPerfData ;
                     24: 
                     25: 
                     26: //==========================================================================//
                     27: //                              Local Functions                             //
                     28: //==========================================================================//
                     29: 
                     30: 
                     31: BOOL /* static */ LogComputerChanged (HDLG hDlg)
                     32:    {  // LogComputerChanged
                     33:    PLOG           pLog ;
                     34:    HWND           hWndObjects ;
                     35:    PPERFSYSTEM    pSysInfo;
                     36:    DWORD          iObjectType ;
                     37:    DWORD          iObjectNum ;
                     38: 
                     39:    pLog = LogData (hDlg) ;
                     40:    hWndObjects = DialogControl (hDlg, IDD_ADDLOGOBJECT) ;
                     41: 
                     42:    if (!pPerfData)
                     43:       {
                     44:       LBReset (hWndObjects) ;
                     45:       return FALSE ;
                     46:       }
                     47: 
                     48:    SetHourglassCursor() ;
                     49: 
                     50:    pSysInfo = GetComputer (hDlg,
                     51:                            IDD_ADDLOGCOMPUTER,
                     52:                            TRUE,
                     53:                            &pPerfData,
                     54:                            &pLog->pSystemFirst) ;
                     55: 
                     56:    if (!pPerfData || !pSysInfo)
                     57:       {
                     58:       LBReset (hWndObjects) ;
                     59:       SetArrowCursor() ;
                     60:       return FALSE ;
                     61:       }
                     62:    else
                     63:       {
                     64:       LBLoadObjects (hWndObjects,
                     65:                      pPerfData, 
                     66:                      pSysInfo, 
                     67:                      pLog->dwDetailLevel, 
                     68:                      NULL,
                     69:                      FALSE) ;
                     70: 
                     71:       iObjectNum = (DWORD) LBNumItems (hWndObjects) ;
                     72:       for (iObjectType = 0 ;
                     73:            iObjectType < iObjectNum ;
                     74:            iObjectType++)
                     75:          {  // for
                     76:          LBSetSelection (hWndObjects, iObjectType) ;
                     77:          }  // for
                     78: 
                     79:       }
                     80: 
                     81:    ComputerChange = FALSE ;
                     82:    DialogEnable (hDlg, IDD_ADDLOGADD, TRUE) ;
                     83:    
                     84:    SetArrowCursor() ;
                     85: 
                     86:    return TRUE ;
                     87:    }  // LogComputerChanged
                     88: 
                     89: 
                     90: void /*static*/ OnLogDestroy (HDLG hDlg)
                     91:    {  // OnLogDestroy
                     92: 
                     93:    dwCurrentDlgID = 0 ;
                     94: 
                     95:    if (!PlayingBackLog ())
                     96:       MemoryFree (pPerfData) ;
                     97: 
                     98:    bAddLineInProgress = FALSE ;
                     99:    }  // OnLogDestroy
                    100:  
                    101: 
                    102: //==========================================================================//
                    103: //                              Message Handlers                            //
                    104: //==========================================================================//
                    105: 
                    106: 
                    107: void /* static */ OnInitAddLogDialog (HDLG hDlg)
                    108:    {  // OnInitAddLogDialog
                    109:    TCHAR          szRemoteComputerName[MAX_COMPUTERNAME_LENGTH + 3] ;
                    110: 
                    111:    bAddLineInProgress = TRUE ;
                    112:    if (PlayingBackLog())
                    113:       {
                    114:       pPerfData = DataFromIndexPosition (&(PlaybackLog.StartIndexPos), NULL) ;
                    115:       GetPerfComputerName(pPerfData, szRemoteComputerName);
                    116:       DialogSetString (hDlg, IDD_ADDLOGCOMPUTER, szRemoteComputerName);
                    117:       DialogEnable (hDlg, IDD_ADDLOGELLIPSES, TRUE) ;
                    118:       }
                    119:    else
                    120:       {
                    121:       pPerfData = MemoryAllocate (STARTING_SYSINFO_SIZE) ;
                    122:       DialogSetString (hDlg, IDD_ADDLOGCOMPUTER, LocalComputerName) ;
                    123:       DialogEnable (hDlg, IDD_ADDLOGELLIPSES, FALSE) ;
                    124:       }
                    125: 
                    126:    LogComputerChanged (hDlg) ;
                    127: 
                    128:    DialogEnable (hDlg, IDD_ADDLOGOBJECTTEXT, TRUE) ;
                    129:    DialogEnable (hDlg, IDD_ADDLOGOBJECT, TRUE) ;
                    130: 
                    131:    WindowCenter (hDlg) ;
                    132: 
                    133:    dwCurrentDlgID = HC_PM_idDlgEditAddToLog ;
                    134: 
                    135:    }  // OnInitAddLogDialog
                    136: 
                    137: 
                    138: void /* static */ OnLogComputer (HDLG hDlg)
                    139: /*
                    140:    Effect:        Put up the select Domain/Computer dialog. Allow the user
                    141:                   to select the computer. Check for user entering a domain
                    142:                   instead. Place the selected computer in the readonly 
                    143:                   edit box.
                    144: */
                    145:    {  // OnLogComputer
                    146:    TCHAR          szComputer [MAX_SYSTEM_NAME_LENGTH + 1] ;
                    147: 
                    148:    if (ChooseComputer (hDlg, szComputer))
                    149:       {
                    150:       DialogSetString (hDlg, IDD_ADDLOGCOMPUTER, szComputer) ;
                    151:       LogComputerChanged (hDlg) ;
                    152:       }  // if
                    153:    }  // OnLogComputer
                    154: 
                    155: 
                    156: 
                    157: void /* static */ OnAddToLog (HDLG hDlg)
                    158: /*
                    159:    Effect:        Perform all actions needed when the user clicks on
                    160:                   the add button. In particular, determine if the required
                    161:                   fields of the dialog have valid values. If so, go ahead
                    162:                   and add a LOGENTRY record in the log. If the computer 
                    163:                   being logged is not already logged, add a LOGSYSTEMENTRY 
                    164:                   as well.
                    165: 
                    166:    Assert:        We have valid values for computer and object, since we
                    167:                   always control these fields.
                    168: */
                    169:    {  // OnAddToLog
                    170:    TCHAR          szComputer [MAX_SYSTEM_NAME_LENGTH + 1] ;
                    171:    TCHAR          szObjectType [PerfObjectLen + 1] ;
                    172:    DWORD          iObjectType ;
                    173:    DWORD          iObjectNum ;
                    174:    HWND           hWndObjectTypes ;
                    175:    PPERF_OBJECT_TYPE    pObject ;
                    176:    PLOG           pLog ;
                    177: 
                    178:    pLog = LogData (hWndLog) ;
                    179: 
                    180:    DialogText (hDlg, IDD_ADDLOGCOMPUTER, szComputer) ;
                    181: 
                    182:    if (ComputerChange)
                    183:       {
                    184:       // if computer has changed, don't want to continue
                    185:       // because the perfdata may have changed
                    186:       LogComputerChanged (hDlg) ;
                    187:       return ;
                    188:       }
                    189: 
                    190:    hWndObjectTypes = DialogControl(hDlg, IDD_ADDLOGOBJECT) ;
                    191: 
                    192:    iObjectNum = (DWORD) LBNumItems (hWndObjectTypes) ;
                    193: 
                    194:    LBSetRedraw (hWndLogEntries, FALSE) ;
                    195:    
                    196:    for (iObjectType = 0 ;
                    197:         iObjectType < iObjectNum ;
                    198:         iObjectType++)
                    199:       {  // for
                    200:       // NOTE: for now, we don't check for duplicate lines
                    201:       if (LBSelected (hWndObjectTypes, iObjectType))
                    202:          {  // if
                    203:          LBString (hWndObjectTypes, iObjectType, szObjectType) ;
                    204:          pObject = (PPERF_OBJECT_TYPE) LBData (hWndObjectTypes, iObjectType) ;
                    205: 
                    206:          // eliminate duplicates here
                    207:          if (LogFindEntry(szComputer, pObject->ObjectNameTitleIndex) ==
                    208:              LOG_ENTRY_NOT_FOUND)
                    209:             {
                    210:             LogAddEntry (hWndLogEntries,
                    211:                          szComputer,
                    212:                          szObjectType,
                    213:                          pObject->ObjectNameTitleIndex) ;
                    214:             }
                    215:          }  // if
                    216:       }  // for
                    217: 
                    218:    LBSetRedraw (hWndLogEntries, TRUE) ;
                    219: 
                    220:    DialogSetText (hDlg, IDD_ADDLOGDONE, IDS_DONE) ;
                    221:    
                    222:    if (pLog->iStatus == iPMStatusCollecting)
                    223:       {
                    224:       LogWriteSystemCounterNames (hWndLog, pLog) ;
                    225:       }
                    226:    }  // OnAddToLog
                    227: 
                    228: 
                    229: 
                    230: int FAR WINAPI AddLogDlgProc (HWND hDlg, WORD msg, 
                    231:                               WPARAM wParam, LONG lParam)
                    232:    {  // AddLogDlg
                    233:    switch(msg)
                    234:       {
                    235:       case WM_INITDIALOG:
                    236:          OnInitAddLogDialog (hDlg) ;
                    237:          return(TRUE);
                    238: 
                    239:       case WM_COMMAND:
                    240:          switch(LOWORD(wParam))
                    241:             {
                    242: //            case IDD_OK:
                    243:             case IDD_CANCEL:
                    244:                EndDialog(hDlg,0);
                    245:                return(TRUE);
                    246: 
                    247:             case IDD_OK:
                    248:             case IDD_ADDLOGADD:
                    249:                SetHourglassCursor() ;
                    250:                OnAddToLog (hDlg) ;
                    251:                SetArrowCursor() ;
                    252:                break ;
                    253: 
                    254:             case IDD_ADDLOGDONE:
                    255:                EndDialog (hDlg, 0) ;
                    256:                break ;
                    257: 
                    258:             case IDD_ADDLOGELLIPSES:
                    259:                SetHourglassCursor() ;
                    260:                OnLogComputer (hDlg) ;
                    261:                SetArrowCursor() ;
                    262:                break ;
                    263: 
                    264: 
                    265:             case IDD_ADDLOGCOMPUTER:
                    266:                if (HIWORD (wParam) == EN_UPDATE)
                    267:                   {
                    268:                   ComputerChange = TRUE ;
                    269:                   DialogEnable (hDlg, IDD_ADDLOGADD, FALSE) ;
                    270:                   }
                    271:                else if (HIWORD (wParam) == EN_KILLFOCUS)
                    272:                   {
                    273:                   if (ComputerChange)
                    274:                      {
                    275:                      TCHAR    szComputer [MAX_SYSTEM_NAME_LENGTH + 3] ;
                    276: 
                    277:                      DialogText (hDlg, IDD_ADDLOGCOMPUTER, szComputer) ;
                    278:                      LogComputerChanged (hDlg) ;
                    279:                      }
                    280:                   }
                    281:                break ;
                    282: 
                    283:             case IDD_ADDLOGHELP:
                    284:                CallWinHelp (dwCurrentDlgID) ;
                    285:                break ;
                    286: 
                    287:             default:
                    288:                break;
                    289:             }
                    290:          break;
                    291: 
                    292:       case WM_DESTROY:
                    293:          OnLogDestroy (hDlg) ;
                    294:          break ;
                    295: 
                    296:       default:
                    297:          break;
                    298:       }
                    299: 
                    300:    return (FALSE);
                    301:    }  // AddLogDlgProc
                    302: 
                    303: 
                    304: 
                    305: BOOL AddLog (HWND hWndParent)
                    306:    {  // AddLog
                    307:    if (DialogBox (hInstance, idDlgAddLog, 
                    308:                   hWndParent, (DLGPROC) AddLogDlgProc))
                    309:       {  // if
                    310:       return (TRUE) ;
                    311:       }  // if
                    312:    return (FALSE) ;
                    313:    }  // AddLog

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.