Some dialogs and data modules in my code need to delay execution and do this by calling PostMessage(). This is not across modules, i.e. the datamodule will have the handler for the PostMessage issued there, so will a dialog.
There is (of course?) interaction between code in the different modules.
I want to trace in what order some specific messages are processed when my program runs.
(How) can I do this in Delphi XE2?
Everything runs in the main UI thread.
Additional notes:
The cleanest way to do this is to log the messages. Logging allows you to inspect the operation of the program without disturbing it as can happen with interactive debugging breakpoints. And for message processing, as your have discovered, the disturbance of breakpoints makes understanding the flow rather difficult.
Since you are posting the messages, they are handled by the thread's message queue. Assuming that the thread in question is the main UI thread, then you can use Application.OnMessage
as your hook to perform logging. All queued messages that are handled by the VCL message loop pass through this event. It is usually best to use a TApplicationEvents
instance to handle Application
events.