//==========================================================================// // Includes // //==========================================================================// #include #include #include "setedit.h" #include "addline.h" #include "grafdata.h" // for ChartInsertLine, ChartDeleteLine #include "graph.h" // for SizeGraphComponents #include "legend.h" // for LegendAddItem #include "line.h" // for LineAllocate, LineFree. #include "pmemory.h" // for MemoryXXX (mallloc-type) routines #include "perfdata.h" // for QueryPerformanceData #include "perfmops.h" // for dlg_error_box #include "system.h" // for SystemGet #include "utils.h" #include "counters.h" #include "pmhelpid.h" // Help IDs //==========================================================================// // Constants // //==========================================================================// #define ADDLINEDETAILLEVEL PERF_DETAIL_WIZARD #define iInitialExplainLen 256 // defines used in owner-drawn items #define OWNER_DRAWN_ITEM 2 #define OWNER_DRAW_FOCUS 1 //==========================================================================// // Local Data // //==========================================================================// // defined in PerfData.c extern WCHAR NULL_NAME[] ; COLORREF argbColors[] = { RGB (0xff, 0x00, 0x00), RGB (0x00, 0x80, 0x00), RGB (0x00, 0x00, 0xff), RGB (0xff, 0xff, 0x00), RGB (0xff, 0x00, 0xff), RGB (0x00, 0xff, 0xff), RGB (0x80, 0x00, 0x00), RGB (0x40, 0x40, 0x40), RGB (0x00, 0x00, 0x80), RGB (0x80, 0x80, 0x00), RGB (0x80, 0x00, 0x80), RGB (0x00, 0x80, 0x80), RGB (0x40, 0x00, 0x00), RGB (0x00, 0x40, 0x00), RGB (0x00, 0x00, 0x40), RGB (0x00, 0x00, 0x00) } ; TCHAR *apszScaleFmt[] = { TEXT("%7.7f"), TEXT("%6.6f"), TEXT("%5.5f"), TEXT("%4.4f"), TEXT("%3.3f"), TEXT("%2.2f"), TEXT("%1.1f"), TEXT("%2.1f"), TEXT("%3.1f"), TEXT("%4.1f"), TEXT("%5.1f"), TEXT("%6.1f"), TEXT("%7.1f") } ; #define DEFAULT_SCALE 0 #define NUMBER_OF_SCALE sizeof(apszScaleFmt)/sizeof(apszScaleFmt[0]) int iLineType ; static PPERFDATA pPerfData ; PPERFSYSTEM pSystem ; PLINESTRUCT pLineEdit ; PPERFSYSTEM *ppSystemFirst ; PLINEVISUAL pVisual ; #define bEditLine (pLineEdit != NULL) BOOL ComputerChange ; BOOL InstanceNameChange ; DWORD ParentObjectTitleIndex ; LPTSTR pCurrentSystem; //==========================================================================// // Macros // //==========================================================================// #define InChartAdd() \ (iLineType == LineTypeChart) #define InAlertAdd() \ (iLineType == LineTypeAlert) #define InReportAdd() \ (iLineType == LineTypeReport) #define NumColorIndexes() \ (sizeof (argbColors) / sizeof (argbColors[0])) #define NumWidthIndexes() 5 #define NumStyleIndexes() 4 //==========================================================================// // Forward Declarations // //==========================================================================// BOOL /*static*/ OnObjectChanged (HDLG hDlg) ; //==========================================================================// // Local Functions // //==========================================================================// PPERFINSTANCEDEF ParentInstance ( PPERFINSTANCEDEF pInstance ) { PPERFOBJECT parent_obj ; PPERFINSTANCEDEF parent_instance ; PERF_COUNTER_BLOCK *counter_blk; LONG i ; parent_obj = GetObjectDefByTitleIndex (pPerfData, pInstance->ParentObjectTitleIndex) ; if (!parent_obj) return (NULL) ; // Then get the parent instance. // NOTE: can use unique ID field to match here instead // of name compare. for (i = 0, parent_instance = (PERF_INSTANCE_DEFINITION *) ( (PBYTE)parent_obj + parent_obj->DefinitionLength); i < parent_obj->NumInstances; i++, parent_instance = (PERF_INSTANCE_DEFINITION *) ( (PBYTE)counter_blk + counter_blk->ByteLength)) { // for counter_blk = (PERF_COUNTER_BLOCK *) ( (PBYTE)parent_instance + parent_instance->ByteLength); if ((DWORD)i == pInstance->ParentObjectInstance) return (parent_instance) ; } return (NULL) ; } PPERFOBJECT SelectedObject ( HWND hWndObjects, LPTSTR lpszObjectName ) /* Effect: Return the pObject associated with the currently selected combo-box item of hWndObjects. Set lpszObjectName to the object's name. If no item is selected in the combobox, return NULL. Assert: The pObject for each CB item was added when the string was added to the CB, by CBLoadObjects. See Also: LoadObjects. */ { INT_PTR iIndex ; iIndex = CBSelection (hWndObjects) ; if (iIndex == CB_ERR) return (NULL) ; if (lpszObjectName) CBString (hWndObjects, iIndex, lpszObjectName) ; return ((PPERFOBJECT) CBData (hWndObjects, iIndex)) ; } PPERFCOUNTERDEF SelectedCounter ( HWND hWndCounters, LPTSTR lpszCounterName ) /* Effect: Return the pCounter associated with the currently selected LB item of hWndCounters. Set lpszCounterName to the Counter's name. If no item is selected in the listbox, return NULL. Assert: The pCounter for each LB item was added when the string was added to the LB, by LoadCounters. See Also: LoadCounters. */ { INT_PTR iIndex ; iIndex = LBSelection (hWndCounters) ; if (iIndex == LB_ERR) return (NULL) ; if (lpszCounterName) LBString (hWndCounters, iIndex, lpszCounterName) ; return ((PPERFCOUNTERDEF) LBData (hWndCounters, iIndex)) ; } void VisualIncrement ( PLINEVISUAL pVisual ) /* Effect: Cycle through the combinations of color, width, and style to distinguish between lines. The color attributes are like a number: