home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copydelp.exe / DateTimePick / dt.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-11-11  |  1.1 KB  |  53 lines

  1. unit dt;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ComCtrls, ToolWin, Grids, Calendar, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Calendar1: TCalendar;
  12.     DateTimePicker1: TDateTimePicker;
  13.     procedure DateTimePicker1Change(Sender: TObject);
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure Calendar1Change(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm1.DateTimePicker1Change(Sender: TObject);
  30. var
  31.    Year, Month, Day : Word;
  32. begin
  33.   DecodeDate(DateTimePicker1.Date, Year, Month, Day);
  34.   Calendar1.Month := Month;
  35.   Calendar1.Day := Day;
  36. end;
  37.  
  38. procedure TForm1.FormCreate(Sender: TObject);
  39. begin
  40.    DateTimePicker1.Align := alTop;
  41.    Calendar1.Align := alClient;
  42. end;
  43.  
  44. procedure TForm1.Calendar1Change(Sender: TObject);
  45. var
  46.    Year, Month, Day : Word;
  47. begin
  48.    DecodeDate(DateTimePicker1.Date, Year, Month, Day);
  49.    DateTimePicker1.Date := EncodeDate(Year, Month, Calendar1.Day);
  50. end;
  51.  
  52. end.
  53.