Page 1 of 1

Font proporcional a la resolucion

Posted: Fri Sep 20, 2019 10:52 am
by hmpaquito
Hola a todos,

Quería ajustar el tamaño de los fonts a la resolucion de la pantalla.

He buscado en el foro y no he encontrado nada.

Se trataria de que al momento de definir el font se le pueda decir el ancho, alto según la resolucion de la pantalla

DEFINE FONT oFont "Arial" SIZE nWidth, nHeight

Re: Font proporcional a la resolucion

Posted: Sat Sep 21, 2019 10:13 am
by Silvio.Falconi
these function load fonts from system

Code: Select all


//___ manejo de fuentes © Paco García 2006 ____________________________________//

#pragma BEGINDUMP
#include "Windows.h"
#include "hbapi.h"

HB_FUNC( GETDEFAULTFONTNAME )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retc( lf.lfFaceName );
}

HB_FUNC( GETDEFAULTFONTHEIGHT )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retni( lf.lfHeight );
}

HB_FUNC( GETDEFAULTFONTWIDTH )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retni( lf.lfWidth );
}

HB_FUNC( GETDEFAULTFONTITALIC )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) lf.lfItalic );
}

HB_FUNC( GETDEFAULTFONTUNDERLINE )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) lf.lfUnderline );
}

HB_FUNC( GETDEFAULTFONTBOLD )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) ( lf.lfWeight == 700 ) );
}

HB_FUNC( GETDEFAULTFONTSTRIKEOUT )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
      GetObject( ( HFONT ) hFont  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
      hb_retl( (BOOL) lf.lfStrikeOut );
}


HB_FUNC( GETDEFAULTFONTNAME2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retc( lf.lfFaceName );
}

HB_FUNC( GETDEFAULTFONTHEIGHT2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
    GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retni( lf.lfHeight );
}

HB_FUNC( GETDEFAULTFONTWIDTH2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retni( lf.lfWidth );
}

HB_FUNC( GETDEFAULTFONTITALIC2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) lf.lfItalic );
}

HB_FUNC( GETDEFAULTFONTUNDERLINE2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) lf.lfUnderline );
}

HB_FUNC( GETDEFAULTFONTBOLD2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) ( lf.lfWeight == 700 ) );
}

HB_FUNC( GETDEFAULTFONTSTRIKEOUT2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

      GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
      hb_retl( (BOOL) lf.lfStrikeOut );
}


#pragma ENDDUMP