From 388275aa0097f35eaf2a9e53bb82d31996d17b20 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 24 Jan 2010 22:49:32 +0000 Subject: [PATCH] 2010-01-24 23:46 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_prn1.c * contrib/hbwin/win_tprn.prg * win_CheckPrnDrvFormat(): Replaced error strings with error codes to avoid storing fixed language messages in low-level code. ! Fixed MSVC warning about potentially uninitialized variable. --- harbour/ChangeLog | 8 ++++++ harbour/contrib/hbwin/win_prn1.c | 39 ++++++++++++++++++------------ harbour/contrib/hbwin/win_tprn.prg | 4 +-- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 93c729e0f7..7888b5479d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-24 23:46 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_prn1.c + * contrib/hbwin/win_tprn.prg + * win_CheckPrnDrvFormat(): Replaced error strings with + error codes to avoid storing fixed language messages in + low-level code. + ! Fixed MSVC warning about potentially uninitialized variable. + 2010-01-24 23:18 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/hbwin.ch * contrib/hbwin/win_prn1.c diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index 017d007e26..d237bc5740 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -575,7 +575,7 @@ HB_FUNC( WIN_LOADBITMAPFILE ) #define CHECKPNGFORMAT 4120 #endif -static HB_BOOL hbwin_CheckPrnDrvFormat( HDC hDC, int iType, const void * pImgBuf, ULONG ulSize, PHB_ITEM pItmErrMsg ) +static HB_BOOL hbwin_CheckPrnDrvFormat( HDC hDC, int iType, const void * pImgBuf, ULONG ulSize, int * piErrCode ) { if( hDC && iType && pImgBuf && ulSize >= sizeof( BITMAPCOREHEADER ) ) { @@ -585,47 +585,56 @@ static HB_BOOL hbwin_CheckPrnDrvFormat( HDC hDC, int iType, const void * pImgBuf { int iRes = iType = ( iType == HB_WIN_BITMAP_JPEG ? CHECKJPEGFORMAT : CHECKPNGFORMAT ); - iRes = ExtEscape( hDC, QUERYESCSUPPORT, sizeof(iRes), ( LPCSTR ) &iRes, 0, 0 ); + iRes = ExtEscape( hDC, QUERYESCSUPPORT, sizeof( iRes ), ( LPCSTR ) &iRes, 0, 0 ); if( iRes > 0 ) { - if( ExtEscape( hDC, iType, ulSize, ( LPCSTR ) pImgBuf, sizeof(iRes), ( LPSTR ) &iRes ) > 0 ) + if( ExtEscape( hDC, iType, ulSize, ( LPCSTR ) pImgBuf, sizeof( iRes ), ( LPSTR ) &iRes ) > 0 ) { - if( pItmErrMsg && iRes != 1 ) - hb_itemPutC( pItmErrMsg, "CHECKFORMAT failure" ); - - return iRes == 1; + if( iRes == 1 ) + return HB_TRUE; + else + { + if( piErrCode ) + *piErrCode = 4; + return HB_FALSE; + } } else { - if( pItmErrMsg ) - hb_itemPutC( pItmErrMsg, "Invalid source devmode for ESCSUPPORT" ); - + if( piErrCode ) + *piErrCode = 3; return HB_FALSE; } } else { - if( pItmErrMsg ) - hb_itemPutC( pItmErrMsg, "QUERYESCSUPPORT Not Implemented" ); - + if( piErrCode ) + *piErrCode = 2; return HB_FALSE; } } } else + { + if( piErrCode ) + *piErrCode = 1; return HB_FALSE; + } } HB_FUNC( WIN_CHECKPRNDRVFORMAT ) { const char * pImgBuf = hb_parc( 2 ); + int iErrCode = 0; - hb_retl( hbwin_CheckPrnDrvFormat( hbwapi_par_HDC( 1 ), hbwin_BitmapType( pImgBuf ), pImgBuf, hb_parclen( 2 ), hb_param( 3, HB_IT_BYREF ) ) ); + hb_retl( hbwin_CheckPrnDrvFormat( hbwapi_par_HDC( 1 ), hbwin_BitmapType( pImgBuf ), pImgBuf, hb_parclen( 2 ), &iErrCode ) ); + + hb_storni( iErrCode, 3 ); } HB_FUNC( WIN_DRAWBITMAP ) { - BITMAPINFO * pbmi; + BITMAPINFO * pbmi = NULL; BYTE * pBits = NULL; HDC hDC = hbwapi_par_HDC( 1 ); ULONG ulSize = hb_parclen( 2 ); diff --git a/harbour/contrib/hbwin/win_tprn.prg b/harbour/contrib/hbwin/win_tprn.prg index d102b51699..43d24e9f14 100644 --- a/harbour/contrib/hbwin/win_tprn.prg +++ b/harbour/contrib/hbwin/win_tprn.prg @@ -828,8 +828,8 @@ METHOD Draw( oPrn, aRectangle, aDimXY ) CLASS WIN_BMP // Pass a WIN_PRN object r ENDIF RETURN oPrn:DrawBitMap( Self ) -METHOD CheckPrnDrvFormat( oPrn, cErrMsg ) CLASS WIN_BMP - RETURN win_CheckPrnDrvFormat( oPrn:hPrinterDc, ::Bitmap, @cErrMsg ) +METHOD CheckPrnDrvFormat( oPrn, nErrCode ) CLASS WIN_BMP + RETURN win_CheckPrnDrvFormat( oPrn:hPrinterDc, ::Bitmap, @nErrCode ) #ifdef HB_COMPAT_XPP