#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

// Devuelve el ancho en unidades lągicas ( Gr ficas ) de una cadena.
// returns the width of a string in pixels

//----------------------------------------------------------------------------//

CLIPPER GetTextWid() //      hDC, szText [,hFont]    --> nPixelsWidth
{
   HDC   hDC        = _parni( 1 );
   DWORD dwSize;
   BOOL  bDestroyDC = FALSE;
   HFONT hFont = _parni( 3 );
   HFONT hOldFont;

   if( ! hDC )
   {
      bDestroyDC = TRUE;
      hDC = GetDC( GetActiveWindow() );
   }

   if( hFont )
      hOldFont = SelectObject( hDC, hFont );

   dwSize = GetTextExtent( hDC, _parc( 2 ), _parclen( 2 ) );

   if( hFont )
      SelectObject( hDC, hOldFont );

   if( bDestroyDC )
       ReleaseDC( 0, hDC );

   _retni( LOWORD( dwSize ) );

}

//----------------------------------------------------------------------------//

CLIPPER GETTEXTHEI()  // GHT()
{
   TEXTMETRIC tm;
   HWND hWnd = _parni( 1 );
   HDC hDC   = GetDC( hWnd );

   GetTextMetrics( hDC, &tm );

   ReleaseDC( hWnd, hDC );

   _retni( tm.tmHeight );
}

//----------------------------------------------------------------------------//
