IonicWind Software

IWBasic => General Questions => Topic started by: paja on October 31, 2010, 05:10:42 PM

Title: Flush buffer
Post by: paja on October 31, 2010, 05:10:42 PM
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


Title: Re: Flush buffer
Post by: sapero on November 01, 2010, 02:00:37 AM
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