Code: |
unit PersForm;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Panel1: TPanel; Label1: TLabel; Edit1: TEdit; SpeedButtonLoad: TSpeedButton; SpeedButtonSave: TSpeedButton; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; procedure FormCreate(Sender: TObject); procedure SpeedButtonSaveClick(Sender: TObject); procedure SpeedButtonLoadClick(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormDestroy(Sender: TObject); procedure FormPaint(Sender: TObject); private PtList: TCollection; end;
var Form1: TForm1;
implementation
{$R *.DFM}
uses DelphiPt;
procedure TForm1.FormCreate(Sender: TObject); begin PtList := TCollection.Create (TDDHPoint); end;
procedure TForm1.SpeedButtonSaveClick(Sender: TObject); var Str1: TFileStream; Wrap: TWrapper; begin if SaveDialog1.Execute then begin Str1 := TFileStream.Create (SaveDialog1.FileName, fmOpenWrite or fmCreate); try Wrap := TWrapper.Create (self); try Wrap.MyColl.Assign (ptList); Str1.WriteComponent (Wrap); finally Wrap.Free; end; finally Str1.Free; end; end; end;
procedure TForm1.SpeedButtonLoadClick(Sender: TObject); var Str1: TFileStream; Wrap: TWrapper; begin if OpenDialog1.Execute then begin Str1 := TFileStream.Create ( OpenDialog1.Filename, fmOpenRead); try Wrap := TWrapper.Create (self); try Wrap := Str1.ReadComponent (Wrap) as TWrapper; ptList.Assign (Wrap.MyColl); finally Wrap.Free; end; finally Str1.Free; Invalidate; Edit1.Text := 'Point ' + IntToStr (PtList.Count + 1); end; end; end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var Pt: TDDHPoint; begin Pt := PtList.Add as TDDHPoint; Pt.X := X; Pt.Y := Y; Pt.Text := Edit1.Text; Edit1.Text := 'Point ' + IntToStr (PtList.Count + 1); Invalidate; end;
procedure TForm1.FormDestroy(Sender: TObject); begin // empty and destroy the list PtList.Clear; PtList.Free; end;
procedure TForm1.FormPaint(Sender: TObject); var I: Integer; begin for I := 0 to PtList.Count - 1 do TDDHPoint (PtList.Items [I]).Paint (Canvas); end;
end. |
- << Назад
- Вперёд
Просьба писать ваши замечания, наблюдения и все остальное,
что поможет улучшить предоставляемую информацию на этом сайте.
ВСЕ КОММЕНТАРИИ МОДЕРИРУЮТСЯ ВРУЧНУЮ, ТАК ЧТО СПАМИТЬ БЕСПОЛЕЗНО!