From 96e589a9141fb2b31154f4e184322a54daae646c Mon Sep 17 00:00:00 2001 From: Mindaugas Kavaliauskas Date: Wed, 13 Oct 2010 17:01:09 +0000 Subject: [PATCH] 2010-10-13 20:00 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/hbwin/tests/pdfcreat.prg ! fixed warning for whose who uses alternatve sample branch #if 0 * harbour/src/rtl/gtstd/gtstd.c ! fixed console input pooling for Windows (you don't need to keep a key pressed to run application) --- harbour/ChangeLog | 7 +++++++ harbour/contrib/hbwin/tests/pdfcreat.prg | 1 + harbour/src/rtl/gtstd/gtstd.c | 22 ++++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2b694839b1..196bf1730b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2010-10-13 20:00 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) + * harbour/contrib/hbwin/tests/pdfcreat.prg + ! fixed warning for whose who uses alternatve sample branch #if 0 + * harbour/src/rtl/gtstd/gtstd.c + ! fixed console input pooling for Windows (you don't need to keep + a key pressed to run application) + 2010-10-13 09:24 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/idesaveload.prg ! Fixed: GPF reported by Maurizio. diff --git a/harbour/contrib/hbwin/tests/pdfcreat.prg b/harbour/contrib/hbwin/tests/pdfcreat.prg index 64ca23a9ee..7af72b5969 100644 --- a/harbour/contrib/hbwin/tests/pdfcreat.prg +++ b/harbour/contrib/hbwin/tests/pdfcreat.prg @@ -56,6 +56,7 @@ LOCAL oPC, nTime, cDefaultPrinter, cFilename, oPrinter, nEvent := 0 oPrinter:EndDoc() oPrinter:Destroy() #else + oPrinter := NIL ? "Do some printing to PDFCreator printer and press any key..." INKEY(0) #endif diff --git a/harbour/src/rtl/gtstd/gtstd.c b/harbour/src/rtl/gtstd/gtstd.c index 48139e8660..91f6dbda64 100644 --- a/harbour/src/rtl/gtstd/gtstd.c +++ b/harbour/src/rtl/gtstd/gtstd.c @@ -383,13 +383,31 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask ) ch = pGTSTD->keyTransTbl[ bChar ]; } #elif defined( HB_OS_WIN ) - if( !pGTSTD->fStdinConsole || - WaitForSingleObject( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), 0 ) == 0x0000 ) + if( ! pGTSTD->fStdinConsole ) { HB_BYTE bChar; if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 ) ch = pGTSTD->keyTransTbl[ bChar ]; } + else if( WaitForSingleObject( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), 0 ) == WAIT_OBJECT_0 ) + { + INPUT_RECORD ir; + DWORD dwEvents; + while( PeekConsoleInput( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), &ir, 1, &dwEvents ) && dwEvents == 1 ) + { + if( ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown ) + { + HB_BYTE bChar; + if( hb_fsRead( pGTSTD->hStdin, &bChar, 1 ) == 1 ) + { + ch = pGTSTD->keyTransTbl[ bChar ]; + exit; + } + } + else /* Remove from the input queue */ + ReadConsoleInput( ( HANDLE ) hb_fsGetOsHandle( pGTSTD->hStdin ), &ir, 1, &dwEvents ); + } + } #elif defined( __WATCOMC__ ) if( pGTSTD->fStdinConsole ) {