FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Font proporcional a la resolucion
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM

Font proporcional a la resolucion

Posted: Fri Sep 20, 2019 10:52 AM

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

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: Font proporcional a la resolucion

Posted: Sat Sep 21, 2019 10:13 AM
these function load fonts from system

Code (fw): Select all Collapse
//___ 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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion