home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / FUNCTION / METPAINT.C < prev    next >
C/C++ Source or Header  |  1994-01-16  |  2KB  |  65 lines

  1. #include <WinTen.h>
  2. #include <Windows.h>
  3. #include <ClipApi.h>
  4.  
  5. void WindowBoxIn( HDC hDC, RECT * pRect );
  6.  
  7. //----------------------------------------------------------------------------//
  8.  
  9. CLIPPER MeterPaint()         //  hWnd, hDC, nActual, nTotal, nPercent
  10. {
  11.    HWND hWnd = _parni( 1 );
  12.    HDC  hDC  = _parni( 2 );
  13.    RECT rc, rcClient;
  14.    WORD wCol, wRight;
  15.    BYTE cChars[ 4 ];
  16.    WORD wPercent = _parni( 5 );
  17.  
  18.    if( wPercent == 100 )
  19.    {
  20.        cChars[ 0 ] = '1';
  21.        cChars[ 1 ] = '0';
  22.    }
  23.    else
  24.    {
  25.        cChars[ 0 ] = ' ';
  26.        cChars[ 1 ] = ( wPercent < 10 ? ' ' : ( BYTE ) ( wPercent / 10 )   + '0' );
  27.    }
  28.    cChars[ 2 ] = ( BYTE ) ( wPercent % 10 )   + '0';
  29.    cChars[ 3 ] = '%';
  30.  
  31.    GetClientRect( hWnd, &rc );
  32.  
  33.    rcClient.top    = rc.top;
  34.    rcClient.left   = rc.left;
  35.    rcClient.bottom = rc.bottom - 1;
  36.    rcClient.right  = rc.right  - 1;
  37.  
  38.    wCol   = ( ( rc.right - rc.left ) / 2 ) - 16;
  39.    wRight = rc.right;
  40.    rc.top++;
  41.    rc.left++;
  42.    rc.bottom--;
  43.    rc.right = ( WORD ) --rc.right * wPercent / 100;
  44.  
  45.    SetBkColor( hDC, RGB( 0, 0, 255 ) );
  46.    SetTextColor( hDC, RGB( 255, 255, 255 ) );
  47.  
  48.    ExtTextOut( hDC, wCol, 2, ETO_CLIPPED | ETO_OPAQUE, &rc, cChars, 4, 0 );
  49.  
  50.    WindowBoxIn( hDC, &rcClient );
  51.  
  52.    SetBkColor( hDC, RGB( 192, 192, 192 ) );
  53.    SetTextColor( hDC, 0 );
  54.  
  55.    rc.left  = rc.right + 1;
  56.    rc.right = wRight - 1;
  57.  
  58.    if( wPercent < 100 )
  59.        ExtTextOut( hDC, wCol, 2, ETO_CLIPPED | ETO_OPAQUE, &rc, cChars, 4, 0 );
  60.  
  61.    _retni( 0 );
  62. }
  63.  
  64. //----------------------------------------------------------------------------//
  65.