home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Demos / Cpl / Date / ufrmdt.pas < prev   
Pascal/Delphi Source File  |  1999-08-11  |  1KB  |  65 lines

  1. unit ufrmdt;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, Grids, Calendar, ExtCtrls, ComCtrls, Mask;
  8.  
  9. type
  10.   TfrmDateTime = class(TForm)
  11.     Panel: TPanel;
  12.     btnCancel: TButton;
  13.     btnOK: TButton;
  14.     grpboxDate: TGroupBox;
  15.     Calendar: TCalendar;
  16.     cmboBoxMonth: TComboBox;
  17.     udYear: TUpDown;
  18.     edtYear: TEdit;
  19.     procedure frmDateTimeCreate(Sender: TObject);
  20.     procedure cmboBoxMonthChange(Sender: TObject);
  21.     procedure edtYearChange(Sender: TObject);
  22.     procedure edtYearKeyPress(Sender: TObject; var Key: Char);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TfrmDateTime.frmDateTimeCreate(Sender: TObject);
  34. var
  35.   i: Integer;
  36.  
  37. begin
  38.   for i := Low(LongMonthNames) to High(LongMonthNames) do
  39.     cmboBoxMonth.Items.Add(LongMonthNames[i]);
  40.  
  41.   cmboBoxMonth.ItemIndex := Calendar.Month-1;
  42.   udYear.Position := Calendar.Year;
  43. end;
  44.  
  45. procedure TfrmDateTime.cmboBoxMonthChange(Sender: TObject);
  46. begin
  47.   Calendar.Month := (Sender as TComboBox).ItemIndex + 1;
  48. end;
  49.  
  50. procedure TfrmDateTime.edtYearChange(Sender: TObject);
  51. begin
  52.   Calendar.Year := StrToInt((Sender as TEdit).Text);
  53. end;
  54.  
  55. procedure TfrmDateTime.edtYearKeyPress(Sender: TObject; var Key: Char);
  56. begin
  57.   if (not (Key in ['0'..'9'])) and (Ord(Key) <> VK_BACK) then
  58.   begin
  59.     Key := #0;
  60.     Beep;
  61.   end;
  62. end;
  63.  
  64. end.
  65.