Instead of setting my own font for a program, I simply want to use the current window font. No problem to find out the font, but how about setting the font size ? If my client uses a larger font size I want to use the same in the program.
Thanks
#include "FiveWin.ch"
function Main()
MsgInfo( GetSysFontSize() )
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( GETSYSFONTSIZE )
{
HWND hWnd = GetDesktopWindow();
HDC hDC = GetWindowDC( hWnd );
int iOldMode = SetMapMode( hDC, MM_TEXT );
TEXTMETRIC tm;
GetTextMetrics( hDC, &tm );
SetMapMode( hDC, iOldMode );
ReleaseDC( hWnd, hDC );
hb_retnl( tm.tmHeight );
}
#pragma ENDDUMP
#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 );
}
#pragma ENDDUMP
y en el programa definir de esta manera la fuente de la ventana principal:
::oFont = TFont():New( GetDefaultFontName(), 0, GetDefaultFontHeight(),, )
#include "FiveWin.ch"
function Main()
local oDlg, oFont
DEFINE FONT oFont NAME GetDefaultFontName() SIZE 0, -GetDefaultFontHeight()
DEFINE DIALOG oWnd TITLE "Test" FONT oFont
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 79 guests