DateF.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit DateF;
  2. interface
  3. uses
  4.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  5.   Forms, Dialogs, Dates, StdCtrls;
  6. type
  7.   TDateForm = class(TForm)
  8.     LabelDate: TLabel;
  9.     BtnIncrease: TButton;
  10.     BtnDecrease: TButton;
  11.     BtnAdd10: TButton;
  12.     BtnSubtract10: TButton;
  13.     BtnLeap: TButton;
  14.     BtnToday: TButton;
  15.     procedure BtnIncreaseClick(Sender: TObject);
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure BtnDecreaseClick(Sender: TObject);
  18.     procedure BtnAdd10Click(Sender: TObject);
  19.     procedure BtnSubtract10Click(Sender: TObject);
  20.     procedure FormDestroy(Sender: TObject);
  21.     procedure BtnLeapClick(Sender: TObject);
  22.     procedure BtnTodayClick(Sender: TObject);
  23.   private
  24.     TheDay: TNewDate;
  25.   public
  26.     { Public declarations }
  27.   end;
  28. var
  29.   DateForm: TDateForm;
  30. implementation
  31. {$R *.DFM}
  32. procedure TDateForm.FormCreate(Sender: TObject);
  33. begin
  34.   TheDay := TNewDate.Create (2001, 12, 25);
  35.   LabelDate.Caption := TheDay.GetText;
  36. end;
  37. procedure TDateForm.BtnIncreaseClick(Sender: TObject);
  38. begin
  39.   TheDay.Increase;
  40.   LabelDate.Caption := TheDay.GetText;
  41. end;
  42. procedure TDateForm.BtnDecreaseClick(Sender: TObject);
  43. begin
  44.   TheDay.Decrease;
  45.   LabelDate.Caption := TheDay.GetText;
  46. end;
  47. procedure TDateForm.BtnAdd10Click(Sender: TObject);
  48. begin
  49.   TheDay.Increase (10);
  50.   LabelDate.Caption := TheDay.GetText;
  51. end;
  52. procedure TDateForm.BtnSubtract10Click(Sender: TObject);
  53. begin
  54.   TheDay.Decrease (10);
  55.   LabelDate.Caption := TheDay.GetText;
  56. end;
  57. procedure TDateForm.FormDestroy(Sender: TObject);
  58. begin
  59.   TheDay.Free;
  60. end;
  61. procedure TDateForm.BtnLeapClick(Sender: TObject);
  62. begin
  63.   if TheDay.LeapYear then
  64.     ShowMessage ('Leap year')
  65.   else
  66.     ShowMessage ('NON Leap year');
  67. end;
  68. procedure TDateForm.BtnTodayClick(Sender: TObject);
  69. begin
  70.   TheDay.SetValue (Date);
  71.   LabelDate.Caption := TheDay.GetText;
  72. end;
  73. end.