main.pas

来自「《Kylix程序设计》一书中附带的例程源代码」· PAS 代码 · 共 84 行

PAS
84
字号
unit Main;interfaceuses  Date, SysUtils, Types, Classes, Variants, QGraphics, QControls, QForms, QDialogs,  QStdCtrls;type  TFrmMain = class(TForm)    LCDYear: TLCDNumber;    LCDMonth: TLCDNumber;    LCDDay: TLCDNumber;    BtnInc: TButton;    BtnDecrease: TButton;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);    procedure BtnIncClick(Sender: TObject);    procedure BtnDecreaseClick(Sender: TObject);  private    { Private declarations }    FDate: TMyDate;  public    { Public declarations }  end;var  FrmMain: TFrmMain;implementation{$R *.xfm}procedure TFrmMain.FormCreate(Sender: TObject);var  AYear: Integer;  AMonth: TMonthType;  ADay: TDayType;begin  AYear := 2000;  AMonth := 1;  ADay := 1;  FDate := TMyDate.Create( AYear, AMonth, ADay );  LCDYear.Value := IntToStr( AYear );  LCDMonth.Value := IntToStr( AMonth );  LCDDay.Value := IntToStr( ADay );end;procedure TFrmMain.FormDestroy(Sender: TObject);begin  if Assigned( FDate ) then  begin    FreeAndNil( FDate );  end;end;procedure TFrmMain.BtnIncClick(Sender: TObject);var  AYear: Integer;  AMonth: TMonthType;  ADay: TDayType;begin  FDate.Inc();  FDate.GetDate( AYear, AMonth, ADay );  LCDYear.Value := IntToStr( AYear );  LCDMonth.Value := IntToStr( AMonth );  LCDDay.Value := IntToStr( ADay );end;procedure TFrmMain.BtnDecreaseClick(Sender: TObject);var  AYear: Integer;  AMonth: TMonthType;  ADay: TDayType;begin  FDate.Dec();  FDate.GetDate( AYear, AMonth, ADay );  LCDYear.Value := IntToStr( AYear );  LCDMonth.Value := IntToStr( AMonth );  LCDDay.Value := IntToStr( ADay );end;end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?