Well, it's quite complicated really. I have 2 applications that communicate with each other via a shared memory component. The App2 is like a service and doesn't have a UI, but it calls some 3rd party DLL's. Some of these DLL's send various WM_USER messages with different lparam parameter values, requiring return values. Some of these messages are best handled by the 2nd app, but I wish to transfer some over to the first app via SendMessage.
Trouble is that the main app (App1) waits in a loop for a response from App2 when it executes a command, so there is a hang situation where App1 is waiting for App2 to finish executing a command, and App2 is waiting for a SendMessage reponse from App1. I don't wish to run ProcessMessages in the App1 loop because this will cause timers to execute, but I wish to execute the WM_USER messages. I can see now that I should be able to get around this by disabling the timers while in the loop so I can execute ProcessMessages. I don't know why I didn't think of that earlier. Ross. ----- Original Message ----- From: "Karl @ Work" <[EMAIL PROTECTED]> To: "'NZ Borland Developers Group - Delphi List'" <[email protected]> Sent: Tuesday, July 18, 2006 5:39 PM Subject: RE: [DUG] selective processing of Windows messages > 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 _______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi _______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
