From 8586465c3a606827af68128e3723a611e4e14d7c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 17 Apr 2012 11:03:54 +0000 Subject: [PATCH] 2012-04-17 13:02 UTC+0200 Viktor Szakats (harbour syenar.net) * src/rtl/run.c * src/rtl/hbrunfun.c * experimental: use hb_processRun() on all win targets (was wince targets) instead of system() from C RTL. QUESTION: do the same for all platforms? * contrib/hbwin/win_prn1.c * contrib/hbwin/hbwin.ch * contrib/hbwin/hbwin.hbx + WIN_ENUMFONTS() modified to work also when no HDC is passed. + WIN_ENUMFONTFAMILIES( [ ][, ] ) -> * contrib/gtwvg/wvgcuig.c * contrib/gtwvg/wvgcore.c ! fixed possible GPF in some functions if font name was not passed --- harbour/ChangeLog | 29 ++++++++++++++++---- harbour/contrib/gtwvg/wvgcore.c | 8 +++--- harbour/contrib/gtwvg/wvgcuig.c | 2 +- harbour/contrib/hbwin/hbwin.ch | 2 +- harbour/contrib/hbwin/hbwin.hbx | 1 + harbour/contrib/hbwin/win_prn1.c | 47 ++++++++++++++++++++++++++------ harbour/src/rtl/hbrunfun.c | 2 +- harbour/src/rtl/run.c | 2 +- 8 files changed, 70 insertions(+), 23 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 784b537e8e..e0b0b87aa9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,14 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2012-04-17 13:02 UTC+0200 Viktor Szakats (harbour syenar.net) + * src/rtl/run.c + * src/rtl/hbrunfun.c + * experimental: use hb_processRun() on all win targets + (was wince targets) instead of system() from C RTL. + QUESTION: do the same for all platforms? + + * contrib/hbwin/win_prn1.c + * contrib/hbwin/hbwin.ch + * contrib/hbwin/hbwin.hbx + + WIN_ENUMFONTS() modified to work also when no HDC is passed. + + WIN_ENUMFONTFAMILIES( [ ][, ] ) -> + + * contrib/gtwvg/wvgcuig.c + * contrib/gtwvg/wvgcore.c + ! fixed possible GPF in some functions if font name was not passed + 2012-04-12 12:35 UTC+0200 Viktor Szakats (harbour syenar.net) * INSTALL - + extended TROUBLESHOOTING about generic common-sense - information about not overdoing custom configuration, - especially for C compiler. I didn't specifically include - anything about bcc, but let me here note, that hbmk2 - and Harbour core build system doesn't require bcc32.cfg - and ilink32.cfg to be _present at all_ since quite long, + + extended TROUBLESHOOTING about generic common-sense + information about not overdoing custom configuration, + especially for C compiler. I didn't specifically include + anything about bcc, but let me here note, that hbmk2 + and Harbour core build system doesn't require bcc32.cfg + and ilink32.cfg to be _present at all_ since quite long, so please remove them for best results. 2012-04-12 00:13 UTC+0200 Viktor Szakats (harbour syenar.net) diff --git a/harbour/contrib/gtwvg/wvgcore.c b/harbour/contrib/gtwvg/wvgcore.c index 1fb8991f35..1cde3370b0 100644 --- a/harbour/contrib/gtwvg/wvgcore.c +++ b/harbour/contrib/gtwvg/wvgcore.c @@ -1198,7 +1198,7 @@ HB_FUNC( WVT_DRAWLABEL ) POINT xy = { 0, 0 }; HFONT hFont, hOldFont, hOldFontGui; LOGFONT logfont; /* = { 0 };*/ - void * hText; + void * hText = NULL; logfont.lfEscapement = hb_parni( 5 ) * 10; logfont.lfOrientation = 0; @@ -2912,7 +2912,7 @@ HB_FUNC( WVT_CREATEFONT ) PHB_GTWVT _s = hb_wvt_gtGetWVT(); LOGFONT logfont; /* = { 0,0,0 }; */ - void * hText; + void * hText = NULL; logfont.lfEscapement = hb_parni( 10 ) * 10; logfont.lfOrientation = 0; @@ -2998,7 +2998,7 @@ HB_FUNC( WVT_LOADFONT ) LOGFONT logfont; /* = { 0 }; */ int iSlot = hb_parni( 1 ) - 1; HFONT hFont; - void * hF; + void * hF = NULL; logfont.lfEscapement = hb_parni( 11 ) * 10; logfont.lfOrientation = 0; @@ -3014,7 +3014,7 @@ HB_FUNC( WVT_LOADFONT ) logfont.lfHeight = hb_parnidef( 3, _s->fontHeight ); logfont.lfWidth = hb_parnidef( 4, _s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ); - HB_STRNCPY( logfont.lfFaceName, ( ! HB_ISCHAR( 2 ) ? _s->fontFace : HB_PARSTR( 2, &hF, NULL ) ), HB_SIZEOFARRAY( logfont.lfFaceName ) - 1 ); + HB_STRNCPY( logfont.lfFaceName, ( HB_ISCHAR( 2 ) ? HB_PARSTR( 2, &hF, NULL ) : _s->fontFace ), HB_SIZEOFARRAY( logfont.lfFaceName ) - 1 ); hb_strfree( hF ); hFont = CreateFontIndirect( &logfont ); diff --git a/harbour/contrib/gtwvg/wvgcuig.c b/harbour/contrib/gtwvg/wvgcuig.c index 9a1e9f473b..9f57a243d6 100644 --- a/harbour/contrib/gtwvg/wvgcuig.c +++ b/harbour/contrib/gtwvg/wvgcuig.c @@ -590,7 +590,7 @@ HB_FUNC( WVG_LABEL ) PHB_GTWVT pWVT = hb_wvt_gtGetWVT(); LOGFONT lf; HFONT hFont; - void * hText; + void * hText = NULL; lf.lfEscapement = hb_parni( 6 ) * 10; lf.lfOrientation = 0; diff --git a/harbour/contrib/hbwin/hbwin.ch b/harbour/contrib/hbwin/hbwin.ch index cb0dbd7574..5d60b536a2 100644 --- a/harbour/contrib/hbwin/hbwin.ch +++ b/harbour/contrib/hbwin/hbwin.ch @@ -148,7 +148,7 @@ #define HB_WINPRN_SERVER 6 #define HB_WINPRN_LEN_ 6 -/* WIN_ENUMFONTS() positions for array returned */ +/* WIN_ENUMFONTS()/WIN_ENUMFONTFAMILIES() positions for array returned */ #define HB_WINFONT_NAME 1 #define HB_WINFONT_FIXED 2 #define HB_WINFONT_TRUETYPE 3 diff --git a/harbour/contrib/hbwin/hbwin.hbx b/harbour/contrib/hbwin/hbwin.hbx index d21062f8c5..a94e0abdab 100644 --- a/harbour/contrib/hbwin/hbwin.hbx +++ b/harbour/contrib/hbwin/hbwin.hbx @@ -318,6 +318,7 @@ DYNAMIC WIN_DRAWBITMAP DYNAMIC WIN_ELLIPSE DYNAMIC WIN_ENDDOC DYNAMIC WIN_ENDPAGE +DYNAMIC WIN_ENUMFONTFAMILIES DYNAMIC WIN_ENUMFONTS DYNAMIC WIN_FILLRECT DYNAMIC WIN_GETCHARSIZE diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index 28b8064b89..ac3248a102 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -556,23 +556,52 @@ static int CALLBACK FontEnumCallBack( LOGFONT * lplf, TEXTMETRIC * lpntm, hb_itemRelease( pSubItems ); - return HB_TRUE; + return TRUE; } HB_FUNC( WIN_ENUMFONTS ) { HDC hDC = hbwapi_par_HDC( 1 ); + HB_BOOL fNullDC = ( ! hDC ); + PHB_ITEM pArray = hb_itemArrayNew( 0 ); - if( hDC ) + if( fNullDC ) + hDC = GetDC( NULL ); + + EnumFonts( hDC, ( LPCTSTR ) NULL, ( FONTENUMPROC ) FontEnumCallBack, ( LPARAM ) pArray ); + + if( fNullDC ) + ReleaseDC( NULL, hDC ); + + hb_itemReturnRelease( pArray ); +} + +HB_FUNC( WIN_ENUMFONTFAMILIES ) +{ + HDC hDC = hbwapi_par_HDC( 1 ); + HB_BOOL fNullDC = ( ! hDC ); + LOGFONT Logfont; + PHB_ITEM pArray = hb_itemArrayNew( 0 ); + + memset( &Logfont, 0, sizeof( Logfont ) ); + + Logfont.lfCharSet = ( BYTE ) hb_parnidef( 1, DEFAULT_CHARSET ); + if( HB_ISCHAR( 2 ) ) { - PHB_ITEM pArray = hb_itemArrayNew( 0 ); - - EnumFonts( hDC, ( LPCTSTR ) NULL, ( FONTENUMPROC ) FontEnumCallBack, ( LPARAM ) pArray ); - - hb_itemReturnRelease( pArray ); + void * hText; + HB_STRNCPY( Logfont.lfFaceName, HB_PARSTR( 2, &hText, NULL ), HB_SIZEOFARRAY( Logfont.lfFaceName ) - 1 ); + hb_strfree( hText ); } - else - hb_reta( 0 ); + + if( fNullDC ) + hDC = GetDC( NULL ); + + EnumFontFamiliesEx( hDC, &Logfont, ( FONTENUMPROC ) FontEnumCallBack, ( LPARAM ) pArray, 0 ); + + if( fNullDC ) + ReleaseDC( NULL, hDC ); + + hb_itemReturnRelease( pArray ); } HB_FUNC( WIN_SETCOLOR ) diff --git a/harbour/src/rtl/hbrunfun.c b/harbour/src/rtl/hbrunfun.c index f4dabc7413..fceaa63391 100644 --- a/harbour/src/rtl/hbrunfun.c +++ b/harbour/src/rtl/hbrunfun.c @@ -66,7 +66,7 @@ HB_FUNC( HB_RUN ) if( hb_gtSuspend() == HB_SUCCESS ) { -#if defined( HB_OS_WIN_CE ) +#if defined( HB_OS_WIN ) iResult = hb_fsProcessRun( pszCommand, NULL, 0, NULL, NULL, NULL, NULL, HB_FALSE ); #else diff --git a/harbour/src/rtl/run.c b/harbour/src/rtl/run.c index 71639fd73f..05dd87e341 100644 --- a/harbour/src/rtl/run.c +++ b/harbour/src/rtl/run.c @@ -65,7 +65,7 @@ HB_FUNC( __RUN ) if( pszCommand && hb_gtSuspend() == 0 ) { -#if defined( HB_OS_WIN_CE ) +#if defined( HB_OS_WIN ) hb_fsProcessRun( pszCommand, NULL, 0, NULL, NULL, NULL, NULL, HB_FALSE ); #else char * pszFree = NULL;