FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour keyboard clear buffer
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
keyboard clear buffer
Posted: Thu Feb 01, 2018 11:09 AM
Hello

viewtopic.php?f=3&t=33093&p=194872&hilit=keyboard+clear#p194872

to break a combination of < DO WHILE > and < FOR NEXT > with < RETURN > I'm using

IF LASTKEY() = 13
IF MsgYesNo("Exit from topic collect ?", "EXIT" )
nPage := nPages + 10 // < do while > break
lBreak := .T. // < for next > break
ENDIF
ENDIF


at the end I call -> CLEARKEYBOARD()

the break only works once because the keybord-buffer still shows 13

At the end of the function I test with

MsgAlert( LASTKEY(), "Lastkey" ) still shows 13

any idea :-)

Code (fw): Select all Collapse
#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HB_FUNC( CLEARKEYBOARD )
{
MSG stMsg = { 0 };

HWND hWnd = ( HWND ) hb_parnl( 1 );

while( PeekMessage( &stMsg, hWnd, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) );

hb_ret();
}

#pragma ENDDUMP


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: keyboard clear buffer
Posted: Thu Feb 01, 2018 03:38 PM
Uwe,

Try it this way
Code (fw): Select all Collapse
while( PeekMessage( &stMsg, hWnd, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) )
{
   TranslateMessage( &stMsg );         
   DispatchMessage( &stMsg );  
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: keyboard clear buffer
Posted: Thu Feb 01, 2018 05:00 PM
Antonio,

lastkey() still shows 13

instead of clear I found another solution
for the break and added

__keyboard( "A" ) // 65
lastkey() = 65

Code (fw): Select all Collapse
...
...
        IF LASTKEY() = 13
             IF MsgYesNo("Exit from topic collect ?", "EXIT" )
                  nPage := nPages + 10 // forces the exit from DO WHILE
                  lBreak := .T. // forces the exit from FOR NEXT
                  __keyboard( "A" )
             ENDIF
       ENDIF
       nPage++
       IF nPage > nPages
            EXIT
       ENDIF
   ENDDO
   IF lBreak = .T.
       EXIT
    ENDIF
NEXT nTopic


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion