keyboard clear buffer

keyboard clear buffer

Postby ukoenig » 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: Select all  Expand view

#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.
User avatar
ukoenig
 
Posts: 3464
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: keyboard clear buffer

Postby Antonio Linares » Thu Feb 01, 2018 3:38 pm

Uwe,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 35350
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: keyboard clear buffer

Postby ukoenig » Thu Feb 01, 2018 5: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: Select all  Expand view

...
...
        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 :D
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.
User avatar
ukoenig
 
Posts: 3464
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], ukoenig and 6 guests