May 18, 2024, 08:26:25 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Flush buffer

Started by paja, October 31, 2010, 05:10:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

paja

Hi,

How can I flush keyboard buffer before testing @CODE - FLUSHKEYS does not work. The same problem is with flush buffer for pressing buttons.
If I press button very quicky more times then I get more result - but I need to control it and get only one.

Thanks



sapero

If you want to flush GUI related messages, try the following FlushMessages function, and apply the additional condition with g_IgnoreMessages, where you want to apply the flush:
$include "windowssdk.inc"
' helper global variable
BOOL g_IgnoreMessages


sub FlushMessages()
MSG msg
g_IgnoreMessages = TRUE

while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
DispatchMessage(&msg)
wend

g_IgnoreMessages = FALSE
endsub


sub window_handler(),int
select @MESSAGE
case @IDCONTROL
if (!g_IgnoreMessages)
' TODO: handle controls
endif
endselect
return 0
endsub