Send a message directly from the stream to the object without using the main form

I use a third-party library that uses a lot of threads.

I just started using messages to communicate with the main stream from the stream. This all works, but using SendMessage, as I describe below, seems cumbersome because the main form should send all messages. Is there a way to send a message directly to a frame or object, regardless of the main form?

When starting the program:

 MyMessageNumber1 :=  RegisterWindowMessage('MyUniqueID1');
 MyMessageNumber2 :=  RegisterWindowMessage('MyUniqueID2');

When sending a message without any data, I:

 SendMessage(Application.MainForm.Handle,  MyMessageNumber1) 

My main form has the following:

procedure WndProc(var Message: TMessage); override;
if (Message.Msg = MyMessageNumber1)
  ... call a frame or other object method that handles this particular message
else if (Message.Msg = MyMessageNumber2) then
  ... call another ....
else
  inherited;

In short: the aforementioned WndProc should know much more than I would prefer about all messages and to whom to send them.

How can I send a message directly from a stream so that any object can receive it?

, . ( !):-)

+3
2

, . AllocateHWND . .

SendMessage. PostMessage SendMessage, . PostMessage . , , , PostMessage.

+4

Source: https://habr.com/ru/post/1777563/


All Articles