In a C++ program (embarcadero XE2, vcl) I would like to send window-messages from parent to all child windows.
For this, I registered a windowMessage, send the message with PostMessage(handle,msg,wparam,lparam)
in a loop for all handles and receive it on each dialog with WndProc(TMessage& Message)
.
My problem is to keep track of the open window handles. Since most dialogs are opened via Show()
, multiple of them can run at the same time.
So far I used a std::vector<HWND>
to store the Window-Handles. However, this would require me to keep track of which handle is still valid at a time.
I could solve this by adding a onClose
Handler to the dialogs and call a procedure in the main thread with the dialog's handle as a parameter, so it can be removed from the vector...
Is there a nicer solution, like a self-updating list as in Application.OpenForms
(.NET)? Or maybe a better way to notify child-dialog of an event from the main dialog?