Advertisement
zoltanleo

Untitled

Apr 7th, 2022
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.78 KB | None | 0 0
  1. //child form
  2. type
  3.   TMyRec = packed record
  4.     s1: String;
  5.     s2: String;
  6.   end;      
  7.  
  8.   TForm2 = class(TForm)
  9.   <skiped>
  10.   private
  11.     FMyRec: TMyRec;
  12.     procedure SetMyRec(AValue: TMyRec);
  13.   public
  14.     property MyRec: TMyRec read FMyRec write SetMyRec;
  15.   end;
  16.  
  17. procedure TForm2.SetMyRec(AValue: TMyRec);
  18. begin
  19.   if (FMyRec.s1 <> AValue.s1) then FMyRec.s1:= AValue.s1;
  20.   if (FMyRec.s2 <> AValue.s2) then FMyRec.s2:= AValue.s2;
  21. end;
  22.  
  23. procedure TForm2.FormCreate(Sender: TObject);
  24. begin
  25.   MyRec:= Default(TMyRec);
  26. end;
  27.  
  28. //parent form
  29. procedure TForm1.Button1Click(Sender: TObject);
  30. var
  31.   tf: TForm2;
  32. begin
  33.   tf:= TForm2.Create(Self);
  34.   try
  35.     tf.MyRec.s1:= 'aaaaaa';
  36.     tf.MyRec.s2:= 'ssssss';
  37.     tf.ShowModal;
  38.   finally
  39.     FreeAndNil(tf);
  40.   end;
  41. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement