2010-01-18 14:56 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/src/common/hbver.c
+ added BOOL hb_iswin9x( void ) C function
* harbour/src/rtl/version.c
+ added HB_OSISWIN9X() PRG function
* harbour/src/rtl/gttone.c
% simplified the code using hb_iswin9x() function
TODO: Check if WinCE support WinNT file IO functions and if yes then
replace in src/rtl/filesys.c 'if( hb_iswinnt() )' with
'if( !hb_iswin9x() )'
* harbour/contrib/hbwin/win_tprn.prg
* harbour/contrib/hbwin/win_prn1.c
+ added ::AskProperties in WIN_PRN class
If it is assigned .t. prior to calling ::Create(), a DocumentProperties
dialog is displayed. By Budyanto Dj. borrowed from xHarbour.
NOTE: this modification does not contain win9x hack present in
xHarbour. Please make tests and update this code if necessary
This commit is contained in:
@@ -17,6 +17,29 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-01-18 14:56 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbapi.h
|
||||
* harbour/src/common/hbver.c
|
||||
+ added BOOL hb_iswin9x( void ) C function
|
||||
|
||||
* harbour/src/rtl/version.c
|
||||
+ added HB_OSISWIN9X() PRG function
|
||||
|
||||
* harbour/src/rtl/gttone.c
|
||||
% simplified the code using hb_iswin9x() function
|
||||
|
||||
TODO: Check if WinCE support WinNT file IO functions and if yes then
|
||||
replace in src/rtl/filesys.c 'if( hb_iswinnt() )' with
|
||||
'if( !hb_iswin9x() )'
|
||||
|
||||
* harbour/contrib/hbwin/win_tprn.prg
|
||||
* harbour/contrib/hbwin/win_prn1.c
|
||||
+ added ::AskProperties in WIN_PRN class
|
||||
If it is assigned .t. prior to calling ::Create(), a DocumentProperties
|
||||
dialog is displayed. By Budyanto Dj. borrowed from xHarbour.
|
||||
NOTE: this modification does not contain win9x hack present in
|
||||
xHarbour. Please make tests and update this code if necessary
|
||||
|
||||
2010-01-18 14:36 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* hbwin/hbwapi.h
|
||||
* hbwin/win_prn1.c
|
||||
|
||||
@@ -499,37 +499,81 @@ HB_FUNC( WIN_SETDOCUMENTPROPERTIES )
|
||||
if( lSize > 0 )
|
||||
{
|
||||
PDEVMODE pDevMode = ( PDEVMODE ) hb_xgrab( lSize );
|
||||
int iProp, iProp2;
|
||||
|
||||
DocumentProperties( 0, hPrinter, ( LPTSTR ) lpDeviceName, pDevMode, pDevMode, DM_OUT_BUFFER );
|
||||
|
||||
if( ( iProp = hb_parni( 3 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
pDevMode->dmPaperSize = ( short ) iProp;
|
||||
|
||||
if( HB_ISLOG( 4 ) )
|
||||
pDevMode->dmOrientation = ( short ) ( hb_parl( 4 ) ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT );
|
||||
|
||||
if( ( iProp = hb_parni( 5 ) ) > 0 )
|
||||
pDevMode->dmCopies = ( short ) iProp;
|
||||
|
||||
if( ( iProp = hb_parni( 6 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
pDevMode->dmDefaultSource = ( short ) iProp;
|
||||
|
||||
if( ( iProp = hb_parni( 7 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
pDevMode->dmDuplex = ( short ) iProp;
|
||||
|
||||
if( ( iProp = hb_parni( 8 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
pDevMode->dmPrintQuality = ( short ) iProp;
|
||||
|
||||
if( pDevMode->dmPaperSize == DMPAPER_USER &&
|
||||
( iProp = hb_parni( 9 ) ) > 0 &&
|
||||
( iProp2 = hb_parni( 10 ) ) > 0 )
|
||||
if( DocumentProperties( 0, hPrinter, ( LPTSTR ) lpDeviceName, pDevMode, pDevMode, DM_OUT_BUFFER ) == IDOK )
|
||||
{
|
||||
pDevMode->dmPaperLength = ( short ) iProp;
|
||||
pDevMode->dmPaperWidth = ( short ) iProp2;
|
||||
}
|
||||
DWORD dmFields = 0, fMode;
|
||||
HB_BOOL fUserDialog;
|
||||
int iProp, iProp2;
|
||||
|
||||
bResult = ( ResetDC( hDC, pDevMode ) != NULL );
|
||||
fUserDialog = HB_ISBYREF( 3 ) || HB_ISBYREF( 4 ) ||
|
||||
HB_ISBYREF( 5 ) || HB_ISBYREF( 6 ) ||
|
||||
HB_ISBYREF( 7 ) || HB_ISBYREF( 8 ) ||
|
||||
HB_ISBYREF( 9 ) || HB_ISBYREF( 10 );
|
||||
|
||||
if( ( iProp = hb_parni( 3 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
{
|
||||
pDevMode->dmPaperSize = ( short ) iProp;
|
||||
dmFields |= DM_PAPERSIZE;
|
||||
}
|
||||
|
||||
if( HB_ISLOG( 4 ) )
|
||||
{
|
||||
pDevMode->dmOrientation = ( short ) ( hb_parl( 4 ) ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT );
|
||||
dmFields |= DM_ORIENTATION;
|
||||
}
|
||||
|
||||
if( ( iProp = hb_parni( 5 ) ) > 0 )
|
||||
{
|
||||
pDevMode->dmCopies = ( short ) iProp;
|
||||
dmFields |= DM_COPIES;
|
||||
}
|
||||
|
||||
if( ( iProp = hb_parni( 6 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
{
|
||||
pDevMode->dmDefaultSource = ( short ) iProp;
|
||||
dmFields |= DM_DEFAULTSOURCE;
|
||||
}
|
||||
|
||||
if( ( iProp = hb_parni( 7 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
{
|
||||
pDevMode->dmDuplex = ( short ) iProp;
|
||||
dmFields |= DM_DUPLEX;
|
||||
}
|
||||
|
||||
if( ( iProp = hb_parni( 8 ) ) != 0 ) /* [2007-02-22] don't change if 0 */
|
||||
{
|
||||
pDevMode->dmPrintQuality = ( short ) iProp;
|
||||
dmFields |= DM_PRINTQUALITY;
|
||||
}
|
||||
|
||||
if( pDevMode->dmPaperSize == DMPAPER_USER &&
|
||||
( iProp = hb_parni( 9 ) ) > 0 &&
|
||||
( iProp2 = hb_parni( 10 ) ) > 0 )
|
||||
{
|
||||
pDevMode->dmPaperLength = ( short ) iProp;
|
||||
pDevMode->dmPaperWidth = ( short ) iProp2;
|
||||
dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH;
|
||||
}
|
||||
|
||||
fMode = DM_IN_BUFFER | DM_OUT_BUFFER;
|
||||
if( fUserDialog )
|
||||
fMode |= DM_IN_PROMPT;
|
||||
|
||||
if( DocumentProperties( 0, hPrinter, ( LPTSTR ) lpDeviceName, pDevMode, pDevMode, fMode ) == IDOK )
|
||||
{
|
||||
hb_storni( pDevMode->dmPaperSize, 3 );
|
||||
hb_storl( pDevMode->dmOrientation == DMORIENT_LANDSCAPE, 4 );
|
||||
hb_storni( pDevMode->dmCopies, 5 );
|
||||
hb_storni( pDevMode->dmDefaultSource, 6 );
|
||||
hb_storni( pDevMode->dmDuplex, 7 );
|
||||
hb_storni( pDevMode->dmPrintQuality, 8 );
|
||||
hb_storni( pDevMode->dmPaperLength, 9 );
|
||||
hb_storni( pDevMode->dmPaperWidth, 10 );
|
||||
|
||||
bResult = ( ResetDC( hDC, pDevMode ) != NULL );
|
||||
}
|
||||
}
|
||||
|
||||
hb_xfree( pDevMode );
|
||||
}
|
||||
@@ -558,17 +602,18 @@ HB_FUNC( WIN_GETDOCUMENTPROPERTIES )
|
||||
{
|
||||
PDEVMODE pDevMode = ( PDEVMODE ) hb_xgrab( lSize );
|
||||
|
||||
DocumentProperties( 0, hPrinter, ( LPTSTR ) lpDeviceName, pDevMode, pDevMode, DM_OUT_BUFFER );
|
||||
|
||||
hb_storni( pDevMode->dmPaperSize, 2 );
|
||||
hb_storl( pDevMode->dmOrientation == DMORIENT_LANDSCAPE, 3 );
|
||||
hb_storni( pDevMode->dmCopies, 4 );
|
||||
hb_storni( pDevMode->dmDefaultSource, 5 );
|
||||
hb_storni( pDevMode->dmDuplex, 6 );
|
||||
hb_storni( pDevMode->dmPrintQuality, 7 );
|
||||
hb_storni( pDevMode->dmPaperLength, 8 );
|
||||
hb_storni( pDevMode->dmPaperWidth, 9 );
|
||||
bResult = HB_TRUE;
|
||||
if( DocumentProperties( 0, hPrinter, ( LPTSTR ) lpDeviceName, pDevMode, pDevMode, DM_OUT_BUFFER ) == IDOK )
|
||||
{
|
||||
hb_storni( pDevMode->dmPaperSize, 2 );
|
||||
hb_storl( pDevMode->dmOrientation == DMORIENT_LANDSCAPE, 3 );
|
||||
hb_storni( pDevMode->dmCopies, 4 );
|
||||
hb_storni( pDevMode->dmDefaultSource, 5 );
|
||||
hb_storni( pDevMode->dmDuplex, 6 );
|
||||
hb_storni( pDevMode->dmPrintQuality, 7 );
|
||||
hb_storni( pDevMode->dmPaperLength, 8 );
|
||||
hb_storni( pDevMode->dmPaperWidth, 9 );
|
||||
bResult = HB_TRUE;
|
||||
}
|
||||
|
||||
hb_xfree( pDevMode );
|
||||
}
|
||||
|
||||
@@ -153,6 +153,8 @@ CREATE CLASS WIN_PRN
|
||||
VAR PageNumber INIT 0
|
||||
VAR hPrinterDc INIT 0
|
||||
|
||||
VAR AskProperties INIT .F.
|
||||
|
||||
// These next 6 variables must be set before calling ::Create() if
|
||||
// you wish to alter the defaults
|
||||
VAR FormType INIT 0
|
||||
@@ -221,6 +223,7 @@ METHOD New( cPrinter ) CLASS WIN_PRN
|
||||
|
||||
METHOD Create() CLASS WIN_PRN
|
||||
LOCAL lResult := .F.
|
||||
|
||||
::Destroy() // Finish current print job if any
|
||||
IF ! Empty( ::hPrinterDC := win_CreateDC( ::PrinterName ) )
|
||||
|
||||
@@ -229,42 +232,57 @@ METHOD Create() CLASS WIN_PRN
|
||||
// Set Orientation
|
||||
// Set Duplex mode
|
||||
// Set PrintQuality
|
||||
win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ;
|
||||
::FormType, ::Landscape, ;
|
||||
::Copies, ::BinNumber, ::fDuplexType, ;
|
||||
::fPrintQuality, ::PaperLength, ::PaperWidth )
|
||||
// Set mapping mode to pixels, topleft down
|
||||
win_SetMapMode( ::hPrinterDC, WIN_MM_TEXT )
|
||||
// win_SetTextCharacterExtra( ::hPrinterDC, 0 ) // do not add extra char spacing even if bold
|
||||
// Get Margins etc... here
|
||||
::PageWidth := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALWIDTH )
|
||||
::PageHeight := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALHEIGHT )
|
||||
::LeftMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETX )
|
||||
::RightMargin := ( ::PageWidth - ::LeftMargin ) + 1
|
||||
::PixelsPerInchY := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSY )
|
||||
::PixelsPerInchX := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSX )
|
||||
::LineHeight := Int( ::PixelsPerInchY / 6 ) // Default 6 lines per inch == # of pixels per line
|
||||
::TopMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETY )
|
||||
::BottomMargin := ( ::PageHeight - ::TopMargin ) + 1
|
||||
|
||||
// Set .T. if can print bitmaps
|
||||
::BitMapsOk := win_BitMapsOk( ::hPrinterDC )
|
||||
IF ::AskProperties
|
||||
lResult := win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ;
|
||||
@::FormType, @::Landscape, ;
|
||||
@::Copies, @::BinNumber, ;
|
||||
@::fDuplexType, @::fPrintQuality, ;
|
||||
@::PaperLength, @::PaperWidth )
|
||||
ELSE
|
||||
lResult := win_SetDocumentProperties( ::hPrinterDC, ::PrinterName, ;
|
||||
::FormType, ::Landscape, ;
|
||||
::Copies, ::BinNumber, ;
|
||||
::fDuplexType, ::fPrintQuality, ;
|
||||
::PaperLength, ::PaperWidth )
|
||||
ENDIF
|
||||
|
||||
// supports Colour
|
||||
::NumColors := win_GetDeviceCaps( ::hPrinterDC, WIN_NUMCOLORS )
|
||||
IF !lResult
|
||||
win_DeleteDC( ::hPrinterDC )
|
||||
::hPrinterDC := NIL
|
||||
ELSE
|
||||
// Set mapping mode to pixels, topleft down
|
||||
win_SetMapMode( ::hPrinterDC, WIN_MM_TEXT )
|
||||
// win_SetTextCharacterExtra( ::hPrinterDC, 0 ) // do not add extra char spacing even if bold
|
||||
// Get Margins etc... here
|
||||
::PageWidth := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALWIDTH )
|
||||
::PageHeight := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALHEIGHT )
|
||||
::LeftMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETX )
|
||||
::RightMargin := ( ::PageWidth - ::LeftMargin ) + 1
|
||||
::PixelsPerInchY := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSY )
|
||||
::PixelsPerInchX := win_GetDeviceCaps( ::hPrinterDC, WIN_LOGPIXELSX )
|
||||
::LineHeight := Int( ::PixelsPerInchY / 6 ) // Default 6 lines per inch == # of pixels per line
|
||||
::TopMargin := win_GetDeviceCaps( ::hPrinterDC, WIN_PHYSICALOFFSETY )
|
||||
::BottomMargin := ( ::PageHeight - ::TopMargin ) + 1
|
||||
|
||||
// Set the standard font
|
||||
::SetDefaultFont()
|
||||
::PageNumber := 0
|
||||
::HavePrinted := ::Printing := ::PageInit := .F.
|
||||
::fOldFormType := ::FormType // Last formtype used
|
||||
::fOldLandScape := ::LandScape
|
||||
::fOldBinNumber := ::BinNumber
|
||||
::fNewDuplexType := ::fDuplexType
|
||||
::fNewPrintQuality := ::fPrintQuality
|
||||
::fOldPaperLength := ::PaperLength
|
||||
::fOldPaperWidth := ::PaperWidth
|
||||
lResult := .T.
|
||||
// Set .T. if can print bitmaps
|
||||
::BitMapsOk := win_BitMapsOk( ::hPrinterDC )
|
||||
|
||||
// supports Colour
|
||||
::NumColors := win_GetDeviceCaps( ::hPrinterDC, WIN_NUMCOLORS )
|
||||
|
||||
// Set the standard font
|
||||
::SetDefaultFont()
|
||||
::PageNumber := 0
|
||||
::HavePrinted := ::Printing := ::PageInit := .F.
|
||||
::fOldFormType := ::FormType // Last formtype used
|
||||
::fOldLandScape := ::LandScape
|
||||
::fOldBinNumber := ::BinNumber
|
||||
::fNewDuplexType := ::fDuplexType
|
||||
::fNewPrintQuality := ::fPrintQuality
|
||||
::fOldPaperLength := ::PaperLength
|
||||
::fOldPaperWidth := ::PaperWidth
|
||||
ENDIF
|
||||
ENDIF
|
||||
RETURN lResult
|
||||
|
||||
|
||||
@@ -1144,6 +1144,7 @@ extern HB_EXPORT const char * hb_verFlagsPRG( void ); /* retrieves a stat
|
||||
extern HB_EXPORT const char * hb_verHB_PLAT( void ); /* retrieves a static buffer containing build time HB_PLATFORM setting */
|
||||
extern HB_EXPORT const char * hb_verHB_COMP( void ); /* retrieves a static buffer containing build time HB_COMPILER setting */
|
||||
|
||||
extern HB_EXPORT HB_BOOL hb_iswin9x( void ); /* return .T. if OS == Windows 9x, ME */
|
||||
extern HB_EXPORT HB_BOOL hb_iswinnt( void ); /* return .T. if OS == Windows NT, 2000, XP */
|
||||
extern HB_EXPORT HB_BOOL hb_iswince( void ); /* return .T. if OS is Windows CE or Windows Mobile */
|
||||
extern HB_EXPORT HB_BOOL hb_printerIsReady( const char * pszPrinterName );
|
||||
|
||||
@@ -393,26 +393,48 @@ char * hb_verPlatform( void )
|
||||
return pszPlatform;
|
||||
}
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
static HB_BOOL s_fWinVerInit = HB_FALSE;
|
||||
|
||||
static HB_BOOL s_fWinNT = HB_FALSE;
|
||||
static HB_BOOL s_fWin9x = HB_FALSE;
|
||||
|
||||
static void s_hb_winVerInit( void )
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof( osvi );
|
||||
if( GetVersionEx( &osvi ) )
|
||||
{
|
||||
s_fWinNT = osvi.dwPlatformId == VER_PLATFORM_WIN32_NT; /* && osvi.dwMajorVersion >= 4); */
|
||||
s_fWin9x = osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
|
||||
}
|
||||
s_fWinVerInit = HB_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
HB_BOOL hb_iswinnt( void )
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
static HB_BOOL s_fWinNT = HB_FALSE;
|
||||
static HB_BOOL s_fInited = HB_FALSE;
|
||||
|
||||
if( ! s_fInited )
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof( osvi );
|
||||
if( GetVersionEx( &osvi ) )
|
||||
s_fWinNT = osvi.dwPlatformId == VER_PLATFORM_WIN32_NT; /* && osvi.dwMajorVersion >= 4); */
|
||||
s_fInited = HB_TRUE;
|
||||
}
|
||||
if( ! s_fWinVerInit )
|
||||
s_hb_winVerInit();
|
||||
return s_fWinNT;
|
||||
#else
|
||||
return HB_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_BOOL hb_iswin9x( void )
|
||||
{
|
||||
#if defined( HB_OS_WIN )
|
||||
if( ! s_fWinVerInit )
|
||||
s_hb_winVerInit();
|
||||
return s_fWin9x;
|
||||
#else
|
||||
return HB_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_BOOL hb_iswince( void )
|
||||
{
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
|
||||
@@ -66,10 +66,14 @@
|
||||
|
||||
#if defined( HB_OS_WIN )
|
||||
|
||||
#undef HB_HAS_WIN9X_TONE
|
||||
|
||||
#if defined( HB_CPU_X86 ) && \
|
||||
( defined( __BORLANDC__ ) || defined( _MSC_VER ) || \
|
||||
defined( __WATCOMC__ ) || defined( __MINGW32__ ) )
|
||||
|
||||
#define HB_HAS_WIN9X_TONE
|
||||
|
||||
#if defined( _MSC_VER ) || defined( __WATCOMC__ )
|
||||
#include <conio.h>
|
||||
#endif
|
||||
@@ -240,22 +244,15 @@ void hb_gt_winapi_tone( double dFrequency, double dDuration )
|
||||
/* keep the frequency in an acceptable range */
|
||||
dFrequency = HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 );
|
||||
|
||||
/* If Windows NT or NT2k, use wNtTone, which provides TONE()
|
||||
reset sequence support (new) */
|
||||
if( hb_iswinnt() || hb_iswince() )
|
||||
{
|
||||
#if defined( HB_HAS_WIN9X_TONE )
|
||||
if( hb_iswin9x() )
|
||||
/* If Windows 95 or 98, use w9xTone for chosen C compilers */
|
||||
hb_gt_w9xTone( dFrequency, dDuration );
|
||||
else
|
||||
#endif
|
||||
/* If Windows NT or NT2k, use wNtTone, which redirects TONE() to
|
||||
WIN API Beep() function */
|
||||
hb_gt_wNtTone( dFrequency, dDuration );
|
||||
}
|
||||
else /* If Windows 95 or 98, use w9xTone for chosen C compilers */
|
||||
{
|
||||
#if defined( HB_CPU_X86 ) && \
|
||||
( defined( __BORLANDC__ ) || defined( _MSC_VER ) || \
|
||||
defined( __WATCOMC__ ) || defined( __MINGW32__ ) )
|
||||
hb_gt_w9xTone( dFrequency, dDuration );
|
||||
#else
|
||||
hb_gt_wNtTone( dFrequency, dDuration );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HB_OS_WIN */
|
||||
|
||||
@@ -186,6 +186,11 @@ HB_FUNC( HB_VERSION )
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( HB_OSISWIN9X )
|
||||
{
|
||||
hb_retl( hb_iswin9x() );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_OSISWINNT )
|
||||
{
|
||||
hb_retl( hb_iswinnt() );
|
||||
|
||||
Reference in New Issue
Block a user