[fpc-pascal] Message methods

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Apr 19 18:04:16 CEST 2011


 
 


 dhkblaszyk at zeelandnet.nl hat am 19. April 2011 um 17:48 geschrieben:


>  Hi,
> 
>  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?
> 
>  Regards, Darius
 
Make sure TMsg starts with
 
TMsg = record
  MsgID: DWord;
  ...
 
 
 


> 
> 
> 
>   TForm1 = class(TForm)
>      Button1: TButton;
>      Button2: TButton;
>      procedure Button1Click(Sender: TObject);
>      procedure Button2Click(Sender: TObject);
>      procedure MessageReceiver(var msg: TMsg); message MY_MESSAGE;
>    private
>      { private declarations }
>    public
>      { public declarations }
>    end;
> var    Form1: TForm1;
> implementation
> {$R *.lfm}
> { TForm1 }
> procedure TForm1.Button1Click(Sender: TObject);
>  begin
>    msg.MSGID := MY_MESSAGE;
>    msg.Data := 'Hello World!';
>    Dispatch(msg);
>  end;
> procedure TForm1.Button2Click(Sender: TObject);
>  begin
>    Form2.Show;
>  end;
> procedure TForm1.MessageReceiver(var msg: TMsg);
>  begin
>    ShowMessage(msg.Data);
>  end;   
> 
 
Mattias
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110419/6a154d6f/attachment.html>


More information about the fpc-pascal mailing list