Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DFM:
- object Form15: TForm15
- Left = 0
- Top = 0
- Caption = 'Form15'
- ClientHeight = 187
- ClientWidth = 605
- Color = clBtnFace
- Font.Charset = DEFAULT_CHARSET
- Font.Color = clWindowText
- Font.Height = -11
- Font.Name = 'Tahoma'
- Font.Style = []
- OldCreateOrder = False
- OnCreate = FormCreate
- OnDestroy = FormDestroy
- PixelsPerInch = 96
- TextHeight = 13
- object Memo1: TMemo
- Left = 8
- Top = 8
- Width = 185
- Height = 89
- Lines.Strings = (
- 'Memo1')
- TabOrder = 0
- end
- object Memo2: TMemo
- Left = 208
- Top = 8
- Width = 185
- Height = 89
- Lines.Strings = (
- 'Memo2')
- TabOrder = 1
- end
- object Memo3: TMemo
- Left = 408
- Top = 8
- Width = 185
- Height = 89
- Lines.Strings = (
- 'Memo3')
- TabOrder = 2
- end
- object Edit1: TEdit
- Left = 304
- Top = 128
- Width = 121
- Height = 21
- TabOrder = 3
- Text = 'Edit1'
- end
- object Button1: TButton
- Left = 184
- Top = 126
- Width = 99
- Height = 25
- Caption = 'Send meeesage'
- TabOrder = 4
- OnClick = Button1Click
- end
- end
- Unit
- unit MainU;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
- System.MulticastEventU, Vcl.StdCtrls;
- {$M+,O+}
- {$IFOPT O-}
- {$MESSAGE Fatal 'Optimization _must_ be turned on for this unit to work!'}
- {$ENDIF}
- type
- TForm15 = class(TForm)
- Memo1: TMemo;
- Memo2: TMemo;
- Memo3: TMemo;
- Edit1: TEdit;
- Button1: TButton;
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- FMulticastEvent: TMulticastEvent<TGetStrProc>;
- procedure StrProc1(const message : string);
- procedure StrProc2(const message : string);
- procedure StrProc3(const message : string);
- end;
- var
- Form15: TForm15;
- implementation
- {$R *.dfm}
- procedure TForm15.Button1Click(Sender: TObject);
- begin
- FMulticastEvent.Invoke(Edit1.Text);
- end;
- procedure TForm15.FormCreate(Sender: TObject);
- begin
- FMulticastEvent := TMulticastEvent<TGetStrProc>.Create;
- FMulticastEvent.Add(StrProc1);
- FMulticastEvent.Add(StrProc2);
- FMulticastEvent.Add(StrProc3);
- end;
- procedure TForm15.FormDestroy(Sender: TObject);
- begin
- FMulticastEvent.Free;
- end;
- procedure TForm15.StrProc1(const message: string);
- begin
- Memo1.Lines.Add(message);
- end;
- procedure TForm15.StrProc2(const message: string);
- begin
- Memo2.Lines.Add(message);
- end;
- procedure TForm15.StrProc3(const message: string);
- begin
- Memo3.Lines.Add(message);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement