<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>ZeelandNet Webmail</title>
</head>
<body style="font-family: arial,helvetica,sans-serif;font-size: 13px;">
Hi,<br /><br />I'm trying to understand how message methods work in FPC. For this I created a simple app that shows a message. I also created a second (identical form) and I expected that all message methods related to MY_MESSAGE would be executed when I pressed either one or the other button. This did not happen however even when dispatching through the Application object. Can someone explain me please?<br /><br />Regards, Darius<br /><br /><br />
<div>
<p>  TForm1 = class(TForm)<br />    Button1: TButton;<br />    Button2: TButton;<br />    procedure Button1Click(Sender: TObject);<br />    procedure Button2Click(Sender: TObject);<br />    procedure MessageReceiver(var msg: TMsg); message MY_MESSAGE;<br />  private<br />    { private declarations }<br />  public<br />    { public declarations }<br />  end;</p>
<p>var<br />  Form1: TForm1;</p>
<p>implementation</p>
<p>{$R *.lfm}</p>
<p>{ TForm1 }</p>
<p>procedure TForm1.Button1Click(Sender: TObject);<br />begin<br />  msg.MSGID := MY_MESSAGE;<br />  msg.Data := 'Hello World!';<br />  Dispatch(msg);<br />end;</p>
<p>procedure TForm1.Button2Click(Sender: TObject);<br />begin<br />  Form2.Show;<br />end;</p>
<p>procedure TForm1.MessageReceiver(var msg: TMsg);<br />begin<br />  ShowMessage(msg.Data);<br />end;   </p>
</div>
</body>
</html>