#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>
void WindowBoxIn( HDC hDC, RECT * pRect );
void Gradient( HDC hDC, RECT * rct, COLORREF crStart, COLORREF crEnd, BOOL bVertical );
static far BYTE cChars[ 81 ];
//----------------------------------------------------------------------------//
HARBOUR HB_FUN_METERPAINT( PARAMS ) // hWnd, hDC, nActual, nTotal, porcentage, Texto, lporcentage, 4 colores, font
{
HWND hWnd = ( HWND ) _parnl( 1 );
HDC hDC = ( HDC ) _parnl( 2 );
RECT rc, rcClient, rcG;
WORD wCol, wRow, wRight;
WORD wPercent = _parni( 5 );
char * cText = _parc( 6 );
int iPorcent = _parl( 7 );
DWORD dwPane = _parnl( 8 );
DWORD dwText = _parnl( 9 );
DWORD dwBar = _parnl( 10 );
DWORD dwBText = _parnl( 11 );
HFONT hFont = ( HFONT ) _parnl( 12 );
HFONT hOldFont;
int nLenght = 0;
SIZE nSizes;
cChars[ 0 ] = 0;
if( hFont )
hOldFont = ( HFONT ) SelectObject( hDC, hFont );
if( cText[ 0 ] )
{
lstrcpy( ( char * ) cChars, cText );
nLenght = lstrlen( ( char * ) cChars );
cChars[ nLenght++ ] = ' ';
}
if( iPorcent )
{
if( wPercent == 100 )
{
cChars[ nLenght ] = '1';
cChars[ nLenght + 1 ] = '0';
}
else
{
cChars[ nLenght ] = ' ';
cChars[ nLenght + 1 ] = ( wPercent < 10 ? ' ' : ( BYTE ) ( wPercent / 10 ) + '0' );
}
cChars[ nLenght + 2 ] = ( BYTE ) ( wPercent % 10 ) + '0';
cChars[ nLenght + 3 ] = '%';
nLenght += 4;
}
GetClientRect( hWnd, &rc );
rcClient.top = rc.top;
rcClient.left = rc.left;
rcClient.bottom = rc.bottom - 1;
rcClient.right = rc.right - 1;
GetTextExtentPoint( hDC, ( char * ) cChars, nLenght, &nSizes );
wCol = ( ( rc.right - rc.left ) / 2 ) - ( nSizes.cx / 2 );
wRow = ( ( rc.bottom - rc.top ) / 2 ) - ( nSizes.cy / 2 );
wRight = rc.right;
rc.top++;
rc.left++;
rc.bottom = rc.bottom-2; //--;
rc.right = ( WORD ) --rc.right * wPercent / 100;
SetBkColor( hDC, dwBar );
//Gradient (hDC,&rc, dwBar, dwPane, TRUE);
SetTextColor( hDC, dwBText );
SetBkMode (hDC,1);
ExtTextOut( hDC, wCol, wRow, ETO_CLIPPED | ETO_OPAQUE, &rc, ( char * ) cChars, nLenght, 0 );
WindowBoxIn( hDC, &rcClient );
SetBkColor( hDC, dwPane );
Gradient (hDC,&rc, RGB (255,255,255), dwBar, TRUE);
SetTextColor( hDC, dwText );
rc.left = rc.right + 1;
rc.right = wRight - 1;
//if( wPercent <= 100 )
ExtTextOut( hDC, wCol, wRow, 0, &rc, ( char * ) cChars, nLenght, 0 );
//else
// ExtTextOut( hDC, wCol, wRow, 0, &rc, ( char * ) cChars, nLenght, 0 );
SetBkMode (hDC,2);
if( hFont )
SelectObject( hDC, hOldFont );
_retni( 0 );
}
//----------------------------------------------------------------------------//