unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, StdCtrls, ComCtrls, ToolWin, Clipbrd, Grids;

type
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    CopyButton: TToolButton;
    PasteButton: TToolButton;
    ToolButton4: TToolButton;
    ExitButton: TToolButton;
    ImageList1: TImageList;
    StringGrid1: TStringGrid;
    Memo1: TMemo;
    procedure ExitButtonClick(Sender: TObject);
    procedure CopyButtonClick(Sender: TObject);
    procedure PasteButtonClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses ClipboardFormatUnit;

{$R *.dfm}

procedure TForm1.ExitButtonClick(Sender: TObject);
begin
 Close;
end;

procedure TForm1.CopyButtonClick(Sender: TObject);
var
 LineClipboard:TLineClipboard;
begin
 LineClipboard:=TLineClipboard.Create;

 LineClipboard.LineData.Name:=StringGrid1.Cells[0, StringGrid1.Row];
 LineClipboard.LineData.LastName:=StringGrid1.Cells[1, StringGrid1.Row];
 LineClipboard.LineData.Bothday:=StringGrid1.Cells[2, StringGrid1.Row];
 LineClipboard.LineData.Age:=StrToInt(StringGrid1.Cells[3, StringGrid1.Row]);
 LineClipboard.LineData.Telephone:=StringGrid1.Cells[4, StringGrid1.Row];

 LineClipboard.CopyToClipboard;

 LineClipboard.Free;
end;

procedure TForm1.PasteButtonClick(Sender: TObject);
var
 LineClipboard:TLineClipboard;
begin
 LineClipboard:=TLineClipboard.Create;

 if Clipboard.HasFormat(CF_PERSONDATA) then
  begin
   LineClipboard.PasteFromClipboard;
   StringGrid1.Cells[0, StringGrid1.Row]:=LineClipboard.LineData.Name;
   StringGrid1.Cells[1, StringGrid1.Row]:=LineClipboard.LineData.LastName;
   StringGrid1.Cells[2, StringGrid1.Row]:=LineClipboard.LineData.Bothday;
   StringGrid1.Cells[3, StringGrid1.Row]:=IntToStr(LineClipboard.LineData.Age);
   StringGrid1.Cells[4, StringGrid1.Row]:=LineClipboard.LineData.Telephone;
  end;

 LineClipboard.Free;

 Memo1.Lines.Clear;
 Memo1.PasteFromClipboard;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
 StringGrid1.Cells[0, 0]:='Имя';
 StringGrid1.Cells[1, 0]:='Фамилия';
 StringGrid1.Cells[2, 0]:='День рождения';
 StringGrid1.Cells[3, 0]:='Возраст';
 StringGrid1.Cells[4, 0]:='Телефон';
end;

end.
