User posts posted are never accepted in my form.

I use PostMessageto send messages from another device to the main form, for example:

procedure notify(var Message: TMessage); message 1;

In the procedure, information is displayed in accordance with WParam:

procedure TForm1.notify(var Message: TMessage);
begin
  Case (Message.WParam) of
    1: memo1.Lines.Add('task started');
    2: memo1.Lines.Add('in progress');
  end;
end;

In another block, I send the following messages:

PostMessage(Handle, 1, 2, variable_info);

First of all, what is a message identifier? I replaced it with 1 because its type is cardinal, what should I use instead? And my messages are never accepted because it is Message.WParamnever equal to 1 or 2. What is wrong with my code?


I edited my code as follows: unit1

 const
 WM_MY_MESSAGE = WM_USER + 0;

in the code, I added something like this:

 PostMessage(Handle,WM_MY_MESSAGE, 1,value_sent);

TFormUnit:

  private
  procedure notify(var Message :TMessage); message WM_MY_MESSAGE;

  procedure TFormMain.notify(var Message: TMessage);
  begin
  Case (Message.WParam)of // which is 1
   1:
  //------------------------------------------
  begin
   memo1.Lines.Add('task started');

Usually when PostMessage (Handle, WM_MY_MESSAGE, 1, value_sent); I have to get the message the task started, but this is the same error, nothing happens!

+4
1

. WM_USER ( Messages) .

WM_USER ($ 0400) . :

.

.

const 
  WM_MY_MESSAGE = WM_USER + 0;

Edit:

, PostMessage,

PostMessage(YourForm.Handle,WM_MY_MESSAGE,1,value_sent);

PostMessage(FindWindow(nil,'YourFormName'),WM_MY_MESSAGE,1,value_sent);   
+8

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


All Articles