[DUG] selective processing of Windows messages
Karl at Work
karlreynolds at xtra.co.nz
Tue Jul 18 17:39:41 NZST 2006
> Does anyone know of a component or some easy way to
> selectively process
> the Windows message queue for the application. For instance
> I may want
> a specific message to be processed but nothing else, or I may
> want all
> messages destined for a specific thread.
>
> For example, Application.ProcessMessages(Handle, WM_USER) would be
> perfect.
PeekMessage searches the message queue, eg. (untried)
procedure ProcessMessagesOfType(AHandle: HWND; AMessage: UINT);
var LMsg: TMsg;
begin
while PeekMessage(LMsg, AHandle, AMessage, AMessage, PM_REMOVE) do
begin
TranslateMessage(LMsg);
DispatchMessage(LMsg);
end;
end;
Having said that, I'm curious to know why you want to process the message
queue out of order. I suggest that there's probably a way to get what you
want without having to do that. Maybe you could give us a bit more info
about what you're trying to achieve?
Other functions that might help:
PostThreadMessage targets a message to a particular thread
RegisterWindowMessage is useful to avoid WM_USER+X broadcast conflicts
between forms/apps
Cheers,
Carl
More information about the Delphi
mailing list