From d79a1b7b812cbde6ddf718ebfd6939a24f633e52 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 5 Mar 2010 18:29:41 +0000 Subject: [PATCH] 2010-03-05 19:26 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/gtwin/gtwin.c + Added more code (probably the ugliest I've ever had a chance to create while touching Windows API) for undocumented SetConsolePalette() hack, following Saulius Zrelskis's suggestion. Now it doesn't GPF, but it does nothing else either (could be wrong SYSPAL_ constant, could be anything). From this point I'll let others continue, or delete all undocumented code sections. --- harbour/ChangeLog | 10 ++++++++++ harbour/src/rtl/gtwin/gtwin.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bdd6867c62..6a8f963d09 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-05 19:26 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/gtwin/gtwin.c + + Added more code (probably the ugliest I've ever had a chance + to create while touching Windows API) for undocumented + SetConsolePalette() hack, following Saulius Zrelskis's + suggestion. Now it doesn't GPF, but it does nothing else + either (could be wrong SYSPAL_ constant, could be anything). + From this point I'll let others continue, or delete all + undocumented code sections. + 2010-03-05 18:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmysql/hbmysql.hbc * contrib/rddsql/sddmy/sddmy.hbc diff --git a/harbour/src/rtl/gtwin/gtwin.c b/harbour/src/rtl/gtwin/gtwin.c index 3ffeb97864..6f4c882233 100644 --- a/harbour/src/rtl/gtwin/gtwin.c +++ b/harbour/src/rtl/gtwin/gtwin.c @@ -742,7 +742,7 @@ static void hb_gt_win_SetPalette_Undoc( HB_BOOL bSet, COLORREF * colors ) { static HB_BOOL s_bChecked = HB_FALSE; - typedef VOID ( WINAPI * P_SETCONSOLEPALETTE )( COLORREF * ); + typedef BOOL ( WINAPI * P_SETCONSOLEPALETTE )( HANDLE, HPALETTE, UINT ); static P_SETCONSOLEPALETTE s_pSetConsolePalette; if( ! s_bChecked ) @@ -752,7 +752,36 @@ static void hb_gt_win_SetPalette_Undoc( HB_BOOL bSet, COLORREF * colors ) } if( bSet && s_pSetConsolePalette ) - s_pSetConsolePalette( colors ); + { + #define _NUM_ENTRIES 16 + + LOGPALETTE * lp = hb_xgrab( sizeof( LOGPALETTE ) + sizeof( PALETTEENTRY ) * _NUM_ENTRIES ); + HPALETTE palette; + int tmp; + + lp->palVersion = ( WORD ) 0x0300; + lp->palNumEntries = _NUM_ENTRIES; + + for( tmp = 0; tmp < 16; ++tmp ) + { + lp->palPalEntry[ tmp ].peRed = GetRValue( colors[ tmp ] ); + lp->palPalEntry[ tmp ].peGreen = GetGValue( colors[ tmp ] ); + lp->palPalEntry[ tmp ].peBlue = GetBValue( colors[ tmp ] ); + lp->palPalEntry[ tmp ].peFlags = 0; + } + + palette = CreatePalette( lp ); + + #ifndef SYSPAL_STATIC + #define SYSPAL_STATIC 1 + #endif + + s_pSetConsolePalette( s_HOutput, palette, SYSPAL_STATIC ); + + DeleteObject( palette ); + + hb_xfree( lp ); + } } #endif