<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title></title>
</head>
<body>
<p style="margin: 0px;"><span> </span></p>
<p style="margin: 0px;"> </p>
<div style="margin: 5px 0px 5px 0px;">
<br/>
dhkblaszyk@zeelandnet.nl hat am 19. April 2011 um 17:48 geschrieben:<br/>
<br/>
<blockquote style="margin-left: 0px; padding-left: 10px; border-left: solid 1px blue;" type="cite">
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
</blockquote>
</div>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Make sure TMsg starts with</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">TMsg = record</p>
<p style="margin: 0px;"> MsgID: DWord;</p>
<p style="margin: 0px;"> ...</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;"> </p>
<div style="margin: 5px 0px 5px 0px;">
<blockquote style="margin-left: 0px; padding-left: 10px; border-left: solid 1px blue;" type="cite">
<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 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>
</blockquote>
</div>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Mattias</p>
<p style="margin: 0px;"> </p>
</body>
</html>