2009. november 13., péntek

Emptying the keyboard queue (key messages)


Problem/Question/Abstract:

Emptying the keyboard queue (key messages)

Answer:

Use the procedure below to remove all pending key messages from your own message queue.

Note that you only can empty your own application's message queue, not from that of another process.


program Dummy;

procedure EmptyKeyQueue;
var
  msg: TMsg;
begin
  while PeekMessage(msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE or PM_NOYIELD) do
    ;
end;

begin
  EmptyKeyQueue;
end.

Nincsenek megjegyzések:

Megjegyzés küldése