home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / winnt / perfmon / timeline.c < prev    next >
Text File  |  1994-10-13  |  20KB  |  742 lines

  1.  
  2.  
  3. //==========================================================================//
  4. //                                  Includes                                //
  5. //==========================================================================//
  6.  
  7.  
  8. #include "perfmon.h"
  9. #include "intrline.h"
  10. #include "pmemory.h"        // for MemoryXXX (mallloc-type) routines
  11. #include "timeline.h"
  12. #include "perfmops.h"       // for SystemTimeDateString, et al.
  13. #include "utils.h"
  14. #include "grafdata.h"       // for GraphData
  15.  
  16. //==========================================================================//
  17. //                                  Typedefs                                //
  18. //==========================================================================//
  19.  
  20. typedef struct CHARTDATAPOINTSTRUCT
  21.    {
  22.    int         iLogIndex ;
  23.    int         xDispDataPoint ;
  24.    } CHARTDATAPOINT, *PCHARTDATAPOINT ;
  25.  
  26. typedef struct TLINESTRUCT
  27.    {  // TLINE
  28.    HWND              hWndILine ;
  29.    HFONT             hFont ;
  30.  
  31.    SYSTEMTIME        SystemTimeBegin ;
  32.    SYSTEMTIME        SystemTimeEnd ;
  33.  
  34.    int               yFontHeight ;
  35.    int               xMaxTimeWidth ;
  36.    int               xBegin ;
  37.    int               xEnd ;
  38.    
  39.    RECT              rectStartDate ;
  40.    RECT              rectStartTime ;
  41.    RECT              rectStopDate ;
  42.    RECT              rectStopTime ;
  43.  
  44.    PCHARTDATAPOINT   pChartDataPoint ;
  45.    int               iCurrentStartPos ;
  46.    int               iCurrentStopPos ;
  47.    } TLINE ;
  48.  
  49. typedef TLINE *PTLINE ;
  50.  
  51. void PlaybackChartDataPoint (PCHARTDATAPOINT pChartDataPoint) ;
  52.  
  53. // IntrLineFocus is defined and set/clear in Intrline.c
  54. extern BOOL  IntrLineFocus ;
  55.  
  56. //==========================================================================//
  57. //                                  Constants                               //
  58. //==========================================================================//
  59.  
  60.  
  61. #define dwTLineClassStyle     (CS_HREDRAW | CS_VREDRAW)
  62. #define iTLineClassExtra      (0)
  63. #define iTLineWindowExtra     (sizeof (PTLINE))
  64. #define dwTLineWindowStyle    (WS_CHILD | WS_VISIBLE) 
  65.  
  66. HWND  hTLineWnd ;
  67. BOOL  TLineWindowUp ;
  68.  
  69.  
  70.  
  71. PTLINE TLData (HWND hWndTL)
  72.    {
  73.    return ((PTLINE) GetWindowLong (hWndTL, 0)) ;
  74.    }
  75.  
  76.  
  77. PTLINE AllocateTLData (HWND hWndTL)
  78.    {
  79.    PTLINE         pTLine ;
  80.    PGRAPHSTRUCT   pGraph ;
  81.  
  82.    pGraph = GraphData (hWndGraph) ;
  83.  
  84.    pTLine = MemoryAllocate (sizeof (TLINE)) ;
  85.  
  86.    
  87.    // see if we have to draw the timeline
  88.    if (pGraph &&
  89.       iPerfmonView == IDM_VIEWCHART &&
  90.       pGraph->pLineFirst &&
  91.       pGraph->gOptions.iGraphOrHistogram == LINE_GRAPH)
  92.       {
  93.       pTLine->pChartDataPoint =
  94.          MemoryAllocate (sizeof(CHARTDATAPOINT) *
  95.          (pGraph->gTimeLine.iValidValues+1)) ;
  96.  
  97.  
  98.       if (pTLine->pChartDataPoint != NULL)
  99.          {
  100.          PlaybackChartDataPoint (pTLine->pChartDataPoint) ;
  101.          }
  102.       }
  103.  
  104.    SetWindowLong (hWndTL, 0, (LONG) pTLine) ;
  105.  
  106.    return (pTLine) ;
  107.    }
  108.  
  109.  
  110. int MaxTimeWidth (HDC hDC, 
  111.                   PTLINE pTLine)
  112. /*
  113.    Effect:        Return a reasonable maximum number of pixels to hold
  114.                   expected time and date strings.  
  115.  
  116.    To Do:         When we use the alleged local-date and local-time display
  117.                   functions, we will modify this routine to use them.
  118. */
  119.    {  // MaxTimeWidth
  120.    return (max (TextWidth (hDC, TEXT(" 99 XXX 99 ")),
  121.                 TextWidth (hDC, TEXT(" 99:99:99.9 PM ")))) ;
  122.    }  // MaxTimeWidth
  123.  
  124.  
  125. void TLGetSystemTimeN (HWND hWnd,   
  126.                        int iInterval,
  127.                        SYSTEMTIME *pSystemTime)
  128.    {  // TLGetSystemTimeN
  129.    SendMessage (WindowParent (hWnd), 
  130.                 TL_INTERVAL, 
  131.                 iInterval, (LPARAM) pSystemTime) ;
  132.    }  // TLGetSystemTimeN
  133.  
  134.  
  135.  
  136. void static TLDrawBeginEnd (HDC hDC,
  137.                             PTLINE pTLine)
  138.    {
  139.    TCHAR         szDate [20] ;
  140.    TCHAR         szTime [20] ;
  141.  
  142.    SetTextAlign (hDC, TA_TOP) ;
  143.    SelectFont (hDC, pTLine->hFont) ;
  144.  
  145.    // Draw the begin time
  146.  
  147.    SystemTimeDateString (&(pTLine->SystemTimeBegin), szDate) ;
  148.    SystemTimeTimeString (&(pTLine->SystemTimeBegin), szTime, TRUE) ;
  149.  
  150.    SetTextAlign (hDC, TA_RIGHT) ;
  151.    TextOut (hDC, pTLine->xBegin, 0, 
  152.             szDate, lstrlen (szDate)) ;
  153.    TextOut (hDC, pTLine->xBegin, pTLine->yFontHeight,
  154.             szTime, lstrlen (szTime)) ;
  155.  
  156.    // Draw The end time
  157.  
  158.    SystemTimeDateString (&(pTLine->SystemTimeEnd), szDate) ;
  159.    SystemTimeTimeString (&(pTLine->SystemTimeEnd), szTime, TRUE) ;
  160.  
  161.    SetTextAlign (hDC, TA_LEFT) ;
  162.    TextOut (hDC, pTLine->xEnd, 0,
  163.             szDate, lstrlen (szDate)) ;
  164.    TextOut (hDC, 
  165.             pTLine->xEnd, 
  166.             pTLine->yFontHeight,
  167.             szTime, lstrlen (szTime)) ;
  168.    }
  169.  
  170. void TLineRedraw (HDC hGraphDC, PGRAPHSTRUCT pGraph)
  171.    {
  172.    PTLINE         pTLine ;
  173.  
  174.    if (!hTLineWnd)
  175.       {
  176.       return ;
  177.       }
  178.  
  179.    pTLine = TLData (hTLineWnd) ;
  180.    if (pTLine == NULL)
  181.       {
  182.       return ;
  183.       }
  184.  
  185.    if (pTLine->iCurrentStartPos)
  186.       {
  187.       // redraw start line
  188.       PatBlt (hGraphDC, pTLine->iCurrentStartPos, pGraph->rectData.top,
  189.          1, pGraph->rectData.bottom - pGraph->rectData.top + 1,
  190.          DSTINVERT) ;
  191.       }
  192.  
  193.    if (pTLine->iCurrentStopPos)
  194.       {
  195.       // redraw stop line
  196.       PatBlt (hGraphDC, pTLine->iCurrentStopPos, pGraph->rectData.top,
  197.          1, pGraph->rectData.bottom - pGraph->rectData.top+ 1,
  198.          DSTINVERT) ;
  199.       }
  200.    }  // TLineRedraw
  201.  
  202. void DrawOneTimeIndicator (PTLINE pTLine,
  203.                            PGRAPHSTRUCT pGraph,
  204.                            HDC hGraphDC,
  205.                            int iPos,
  206.                            int *pCurrentPos)
  207.    {
  208.    int               xPos ;
  209.    PCHARTDATAPOINT   pDataPoint ;
  210.  
  211.    // check if it is within current selected range
  212.    if (iPos >= PlaybackLog.StartIndexPos.iPosition &&
  213.       iPos <= PlaybackLog.StopIndexPos.iPosition)
  214.       {
  215.  
  216.       xPos = 0 ;
  217.       pDataPoint = pTLine->pChartDataPoint ;
  218.  
  219.       // check for the x position of this Log Index
  220.       while (pDataPoint->iLogIndex != 0)
  221.          {
  222.          if (iPos >= pDataPoint->iLogIndex)
  223.             {
  224.             if ((pDataPoint+1)->iLogIndex == 0)
  225.                {
  226.                // we have reached the end
  227.                xPos = pDataPoint->xDispDataPoint ;
  228.                break ;
  229.                }
  230.             else if (iPos <= (pDataPoint+1)->iLogIndex)
  231.                {
  232.                // we have found the Log index
  233.                xPos = (pDataPoint+1)->xDispDataPoint ;
  234.                break ;
  235.                }
  236.             }
  237.          else
  238.             {
  239.             // no need to continue if iPos is smaller than the 
  240.             // first Log index on the chart
  241.             break ;
  242.             }
  243.  
  244.          pDataPoint++ ;
  245.          }
  246.  
  247.       if (xPos != *pCurrentPos)
  248.          {
  249.          if (*pCurrentPos)
  250.             {
  251.             // erase the old line
  252.             PatBlt (hGraphDC, *pCurrentPos, pGraph->rectData.top,
  253.                1, pGraph->rectData.bottom - pGraph->rectData.top + 1,
  254.                DSTINVERT) ;
  255.             }
  256.  
  257.          // draw the new line
  258.          *pCurrentPos = xPos ;
  259.  
  260.          if (xPos > 0)
  261.             {
  262.             PatBlt (hGraphDC, xPos, pGraph->rectData.top,
  263.                1, pGraph->rectData.bottom - pGraph->rectData.top + 1,
  264.                DSTINVERT) ;
  265.             }
  266.          }
  267.       }
  268.    else
  269.       {
  270.       if (*pCurrentPos)
  271.          {
  272.          // erase the old line
  273.          PatBlt (hGraphDC, *pCurrentPos, pGraph->rectData.top,
  274.             1, pGraph->rectData.bottom - pGraph->rectData.top + 1,
  275.             DSTINVERT) ;
  276.          }
  277.  
  278.       *pCurrentPos = 0 ;
  279.       }
  280.    }  // DrawOneTimeIndicator
  281.  
  282. void DrawTimeIndicators (PTLINE pTLine, int iStart, int iStop)
  283.    {
  284.  
  285.    HDC            hGraphDC ;
  286.    PGRAPHSTRUCT   pGraph ;
  287.  
  288.    pGraph = GraphData (hWndGraph) ;
  289.    hGraphDC = GetDC (hWndGraph) ;
  290.    if (!hGraphDC || !pGraph)
  291.       {
  292.       return ;
  293.       }
  294.  
  295.    DrawOneTimeIndicator (pTLine, pGraph, hGraphDC, iStart, &pTLine->iCurrentStartPos) ;
  296.    DrawOneTimeIndicator (pTLine, pGraph, hGraphDC, iStop, &pTLine->iCurrentStopPos) ;
  297.  
  298.    ReleaseDC (hWndGraph, hGraphDC) ;
  299.    }
  300.  
  301. void static TLDrawStartStop (HWND hWnd,
  302.                              HDC hDC,
  303.                              PTLINE pTLine)
  304. /*
  305.    Effect:        Draw the start and stop date/times on the bottom of the
  306.                   timeline. Draw the start date/time right justified at the
  307.                   outer edge of the start point and the stop date/time left
  308.                   justified with the outer edge of the stop point.
  309.  
  310.                   Erase previous start and stop date/times in the process.
  311. */
  312.    {  // TLDrawStartStop
  313.    RECT           rectDate ;
  314.    RECT           rectTime ;
  315.    RECT           rectOpaque ;
  316.  
  317.    TCHAR          szDate [30] ;
  318.    TCHAR          szTime [30] ;
  319.  
  320.    int            xStart ;
  321.    int            xStop ;
  322.  
  323.    int            iStart ;
  324.    int            iStop ;
  325.  
  326.    SYSTEMTIME     SystemTimeStart ;
  327.    SYSTEMTIME     SystemTimeStop ;
  328.  
  329.    int            xDateTimeWidth ;
  330.  
  331.  
  332.    SelectFont (hDC, pTLine->hFont) ;
  333.    SetTextAlign (hDC, TA_TOP) ;
  334.  
  335.    //=============================//
  336.    // Get Start Information       //
  337.    //=============================//
  338.  
  339.    xStart = pTLine->xBegin + ILineXStart (pTLine->hWndILine) ;
  340.  
  341.    iStart = ILineStart (pTLine->hWndILine) ;
  342.    TLGetSystemTimeN (hWnd, iStart, &SystemTimeStart) ;
  343.    SystemTimeDateString (&SystemTimeStart, szDate) ;
  344.    SystemTimeTimeString (&SystemTimeStart, szTime, TRUE) ;
  345.  
  346.    xDateTimeWidth = max (TextWidth (hDC, szDate),
  347.                          TextWidth (hDC, szTime)) ;
  348.  
  349.    //=============================//
  350.    // Write Start Date            //
  351.    //=============================//
  352.  
  353.    rectDate.left = xStart - xDateTimeWidth ;
  354.    rectDate.top = pTLine->rectStartDate.top ;
  355.    rectDate.right = xStart ;
  356.    rectDate.bottom = pTLine->rectStartDate.bottom ;
  357.  
  358.    SetTextAlign (hDC, TA_RIGHT) ;
  359.    UnionRect (&rectOpaque, &pTLine->rectStartDate, &rectDate) ;
  360.  
  361.    ExtTextOut (hDC, 
  362.                rectDate.right, rectDate.top,
  363.                ETO_OPAQUE,
  364.                &rectOpaque,
  365.                szDate, lstrlen (szDate),
  366.                NULL) ;
  367.    pTLine->rectStartDate = rectDate ;
  368.  
  369.    //=============================//
  370.    // Write Start Time            //
  371.    //=============================//
  372.    
  373.    rectTime.left = rectDate.left ;
  374.    rectTime.top = pTLine->rectStartTime.top ;
  375.    rectTime.right = rectDate.right ;
  376.    rectTime.bottom = pTLine->rectStartTime.bottom ;
  377.  
  378.    UnionRect (&rectOpaque, &pTLine->rectStartTime, &rectTime) ;
  379.  
  380.    ExtTextOut (hDC, 
  381.                rectTime.right, rectTime.top,
  382.                ETO_OPAQUE,
  383.                &rectOpaque,
  384.                szTime, lstrlen (szTime),
  385.                NULL) ;
  386.    pTLine->rectStartTime = rectTime ;
  387.  
  388.    if (IntrLineFocus)
  389.       {
  390.       UnionRect (&rectOpaque, &rectDate, &rectTime) ;
  391.       DrawFocusRect (hDC, &rectOpaque) ;
  392.       }
  393.  
  394.    //=============================//
  395.    // Get Stop Information        //
  396.    //=============================//
  397.  
  398.    xStop = pTLine->xBegin + ILineXStop (pTLine->hWndILine) ;
  399.  
  400.    iStop = ILineStop (pTLine->hWndILine) ;
  401.    TLGetSystemTimeN (hWnd, iStop, &SystemTimeStop) ;
  402.    SystemTimeDateString (&SystemTimeStop, szDate) ;
  403.    SystemTimeTimeString (&SystemTimeStop, szTime, TRUE) ;
  404.  
  405.    xDateTimeWidth = max (TextWidth (hDC, szDate),
  406.                          TextWidth (hDC, szTime)) ;
  407.  
  408.    //=============================//
  409.    // Write Stop Date             //
  410.    //=============================//
  411.  
  412.    rectDate.left = xStop ;
  413.    rectDate.top = pTLine->rectStopDate.top ;
  414.    rectDate.right = xStop + xDateTimeWidth ;
  415.    rectDate.bottom = pTLine->rectStopDate.bottom ;
  416.  
  417.    SetTextAlign (hDC, TA_LEFT) ;
  418.    UnionRect (&rectOpaque, &pTLine->rectStopDate, &rectDate) ;
  419.  
  420.    ExtTextOut (hDC, 
  421.                rectDate.left, rectDate.top,
  422.                ETO_OPAQUE,
  423.                &rectOpaque,
  424.                szDate, lstrlen (szDate),
  425.                NULL) ;
  426.    pTLine->rectStopDate = rectDate ;
  427.  
  428.    //=============================//
  429.    // Write Stop Time             //
  430.    //=============================//
  431.    
  432.    rectTime.left = rectDate.left ;
  433.    rectTime.top = pTLine->rectStopTime.top ;
  434.    rectTime.right = rectDate.right ;
  435.    rectTime.bottom = pTLine->rectStopTime.bottom ;
  436.  
  437.    UnionRect (&rectOpaque, &pTLine->rectStopTime, &rectTime) ;
  438.  
  439.    ExtTextOut (hDC, 
  440.                rectTime.left, rectTime.top,
  441.                ETO_OPAQUE,
  442.                &rectOpaque,
  443.                szTime, lstrlen (szTime),
  444.                NULL) ;
  445.    pTLine->rectStopTime = rectTime ;
  446.  
  447.    if (IntrLineFocus)
  448.       {
  449.       UnionRect (&rectOpaque, &rectDate, &rectTime) ;
  450.       DrawFocusRect (hDC, &rectOpaque) ;
  451.       }
  452.  
  453.    if (pTLine->pChartDataPoint)
  454.       {
  455.       DrawTimeIndicators (pTLine, iStart, iStop) ;
  456.       }
  457.    }  // TLDrawStartStop
  458.  
  459.  
  460.  
  461. //==========================================================================//
  462. //                              Message Handlers                            //
  463. //==========================================================================//
  464.  
  465.  
  466.  
  467. void static OnCreate (HWND hWnd)
  468.    {  // OnCreate
  469.    PTLINE         pTLine ;
  470.    HDC            hDC ;
  471.  
  472.    pTLine = AllocateTLData (hWnd) ;
  473.    
  474.    pTLine->hFont = hFontScales ;
  475.  
  476.    hDC = GetDC (hWnd) ;
  477.    SelectFont (hDC, hFontScales) ;
  478.  
  479.    pTLine->yFontHeight = FontHeight (hDC, TRUE) ;
  480.    pTLine->xMaxTimeWidth = MaxTimeWidth (hDC, pTLine) ;
  481.  
  482.    ReleaseDC (hWnd, hDC) ;
  483.  
  484.    hTLineWnd = hWnd ;
  485.    TLineWindowUp = TRUE ;
  486.  
  487.    pTLine->hWndILine = 
  488.       CreateWindow (szILineClass,                  // class
  489.                     NULL,                          // caption
  490.                     (WS_VISIBLE | WS_CHILD | WS_TABSTOP ),       // window style
  491.                     0, 0,                          // position
  492.                     0, 0,                          // size
  493.                     hWnd,                          // parent window
  494.                     NULL,                          // menu          
  495.                     hInstance,                     // program instance
  496.                     NULL) ;                        // user-supplied data
  497.    }  // OnCreate
  498.  
  499.  
  500. void static OnDestroy (HWND hWnd)
  501.    {
  502.    PTLINE         pTLine ;
  503.  
  504.    pTLine = TLData (hWnd) ;
  505.  
  506.    if (pTLine->pChartDataPoint)
  507.       {
  508.       MemoryFree (pTLine->pChartDataPoint) ;
  509.       }
  510.  
  511.    MemoryFree (pTLine) ;
  512.  
  513.    hTLineWnd = 0 ;
  514.    TLineWindowUp = FALSE ;
  515.  
  516.    }
  517.  
  518.  
  519. void static OnSize (HWND hWnd,
  520.                     int xWidth,
  521.                     int yHeight)
  522. /*
  523.    Effect:        Perform all actions needed when the size of the timeline
  524.                   hWnd has changed. In particular, determine the appropriate
  525.                   size for the ILine window and set the rectangles for the
  526.                   top and bottom displays.
  527. */
  528.    {  // OnSize
  529.    PTLINE         pTLine ;
  530.    int            yLine ;
  531.    int            yDate, yTime ;
  532.    int            xEnd ;
  533.  
  534.    pTLine = TLData (hWnd) ;
  535.  
  536.    xEnd = xWidth - pTLine->xMaxTimeWidth ;
  537.    yLine = pTLine->yFontHeight ;
  538.    yDate = yHeight - 2 * yLine ;
  539.    yTime = yHeight - yLine ;
  540.  
  541.  
  542.    SetRect (&pTLine->rectStartDate,
  543.             0, yDate, 0, yDate + yLine) ;
  544.  
  545.    SetRect (&pTLine->rectStartTime,
  546.             0, yTime, 0, yTime + yLine) ;
  547.  
  548.    SetRect (&pTLine->rectStopDate,
  549.             xEnd, yDate, xEnd, yDate + yLine) ;
  550.  
  551.    SetRect (&pTLine->rectStopTime,
  552.             xEnd, yTime, xEnd, yTime + yLine) ;
  553.  
  554.    MoveWindow (pTLine->hWndILine,
  555.                pTLine->xMaxTimeWidth, 2 * pTLine->yFontHeight,
  556.                xWidth - 2 * pTLine->xMaxTimeWidth,
  557.                yHeight - 4 * pTLine->yFontHeight,
  558.                FALSE) ;
  559.  
  560.    pTLine->xBegin = pTLine->xMaxTimeWidth ;
  561.    pTLine->xEnd = xWidth - pTLine->xMaxTimeWidth ;
  562.    }  // OnSize
  563.  
  564.  
  565. void static OnPaint (HWND hWnd)
  566.    {
  567.    HDC            hDC ;
  568.    PAINTSTRUCT    ps ;
  569.    PTLINE         pTLine ;
  570.  
  571.    hDC = BeginPaint (hWnd, &ps) ;
  572.  
  573.    pTLine = TLData (hWnd) ;
  574.    TLDrawBeginEnd (hDC, pTLine) ;
  575.    TLDrawStartStop (hWnd, hDC, pTLine) ;
  576.  
  577.    EndPaint (hWnd, &ps) ;
  578.    }
  579.  
  580.  
  581. void static OnILineChanged (HWND hWnd)
  582.    {
  583.    HDC            hDC ;
  584.    PTLINE         pTLine ;
  585.  
  586.    pTLine = TLData (hWnd) ;
  587.  
  588.    hDC = GetDC (hWnd) ;
  589.    TLDrawStartStop (hWnd, hDC, pTLine) ;
  590.    ReleaseDC (hWnd, hDC) ;
  591.    }
  592.  
  593.  
  594. //==========================================================================//
  595. //                             Exported Functions                           //
  596. //==========================================================================//
  597.  
  598.  
  599. LONG FAR PASCAL TLineWndProc (HWND hWnd,
  600.                               unsigned msg,
  601.                               WPARAM wParam,
  602.                               LONG lParam)
  603. /*
  604.    Note:          This function must be declared in the application's
  605.                   linker-definition file, perfmon.def file.
  606. */
  607.    {  // TLineWndProc
  608.    BOOL           bCallDefWindowProc ;
  609.    LONG           lReturnValue ;
  610.  
  611.    bCallDefWindowProc = FALSE ;
  612.    lReturnValue = 0L ;
  613.  
  614.    switch (msg)
  615.       {  // switch
  616.       case WM_SETFOCUS:
  617.          {
  618.          PTLINE         pTLine ;
  619.  
  620.          pTLine = TLData (hWnd) ;
  621.          SetFocus (pTLine->hWndILine) ;
  622.          }
  623.          return 0 ;
  624.  
  625.       case WM_KILLFOCUS:
  626.          return 0 ;
  627.  
  628.       case WM_COMMAND:
  629.          OnILineChanged (hWnd) ;
  630.          break ;
  631.  
  632.       case WM_CREATE:
  633.          OnCreate (hWnd) ;
  634.          break ;
  635.  
  636.       case WM_DESTROY:
  637.          OnDestroy (hWnd) ;
  638.          break ;
  639.  
  640.       case WM_PAINT:
  641.          OnPaint (hWnd) ;
  642.          break ;
  643.  
  644.       case WM_SIZE:
  645.          OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
  646.          break ;
  647.  
  648.       default:
  649.          bCallDefWindowProc = TRUE ;
  650.       }  // switch
  651.  
  652.    if (bCallDefWindowProc)
  653.       lReturnValue = DefWindowProc (hWnd, msg, wParam, lParam) ;
  654.  
  655.    return (lReturnValue) ;
  656.    }  // TLineWndProc
  657.  
  658.  
  659.  
  660. BOOL TLineInitializeApplication (void)
  661. /*
  662.    Effect:        Perform all initializations required before an application
  663.                   can create an IntervalLine. In particular, register the 
  664.                   IntervalLine window class.
  665.  
  666.    Called By:     The application, in its InitializeApplication routine.
  667.  
  668.    Returns:       Whether the class could be registered.
  669. */
  670.    {  // TLineInitializeApplication
  671.    WNDCLASS       wc ;
  672.  
  673.    wc.style =           dwTLineClassStyle ;
  674.    wc.lpfnWndProc =     TLineWndProc ;
  675.    wc.cbClsExtra =      iTLineClassExtra ;
  676.    wc.cbWndExtra =      iTLineWindowExtra ;
  677.    wc.hInstance =       hInstance ;
  678.    wc.hIcon =           NULL ;
  679.    wc.hCursor =         LoadCursor (NULL, IDC_ARROW) ;
  680.    wc.hbrBackground =   (HBRUSH) (COLOR_WINDOW + 1) ;
  681.    wc.lpszMenuName =    NULL ;
  682.    wc.lpszClassName =   szTLineClass ;
  683.  
  684.    return (RegisterClass (&wc)) ;
  685.    }  // TLineInitializeApplication
  686.  
  687.  
  688. void TLineSetRange (HWND hWnd, 
  689.                     int iBegin, 
  690.                     int iEnd)
  691.    {
  692.    PTLINE         pTLine ;
  693.  
  694.    pTLine = TLData (hWnd) ;
  695.  
  696.    ILineSetRange (pTLine->hWndILine, iBegin, iEnd) ;
  697.    TLGetSystemTimeN (hWnd, iBegin, &pTLine->SystemTimeBegin) ;
  698.    TLGetSystemTimeN (hWnd, iEnd, &pTLine->SystemTimeEnd) ;
  699.    }
  700.  
  701.  
  702. void TLineSetStart (HWND hWnd,
  703.                     int iStart)
  704.    {
  705.    PTLINE         pTLine ;
  706.  
  707.    pTLine = TLData (hWnd) ;
  708.    ILineSetStart (pTLine->hWndILine, iStart) ;
  709.    }
  710.  
  711.  
  712. void TLineSetStop (HWND hWnd,
  713.                    int iStop)
  714.    {
  715.    PTLINE         pTLine ;
  716.  
  717.    pTLine = TLData (hWnd) ;
  718.    ILineSetStop (pTLine->hWndILine, iStop) ;
  719.    }
  720.  
  721.  
  722. int TLineStart (HWND hWnd)
  723.    {
  724.    PTLINE         pTLine ;
  725.  
  726.    pTLine = TLData (hWnd) ;
  727.  
  728.    return (ILineStart (pTLine->hWndILine)) ;
  729.    }
  730.  
  731.  
  732. int TLineStop (HWND hWnd)
  733.    {
  734.    PTLINE         pTLine ;
  735.  
  736.    pTLine = TLData (hWnd) ;
  737.  
  738.    return (ILineStop (pTLine->hWndILine)) ;
  739.    }
  740.  
  741. 
  742.