home *** CD-ROM | disk | FTP | other *** search
- unit configform;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, ComCtrls; // ComCtrls needed for TDateTimePicker
-
- type
- TConfigurationForm = class(TForm)
- CloseBtn: TButton;
- ApplyBtn: TButton;
- AlignmentRGrp: TRadioGroup;
- DateFormatRGrp: TRadioGroup;
- GroupBox1: TGroupBox;
- PickColourBtn: TButton;
- ComboBox1: TComboBox;
- ColorDialog1: TColorDialog;
- DateModeCD: TCheckBox;
- CancelBtn: TButton;
- procedure CloseBtnClick(Sender: TObject);
- procedure ApplyBtnClick(Sender: TObject);
- procedure PickColourBtnClick(Sender: TObject);
- procedure CancelBtnClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- procedure SetConfig;
- procedure GetConfig;
- public
- { Public declarations }
- mbackcol, textcol, titlebackcol, titletextcol, trailcol : TColor;
- end;
-
- var
- ConfigurationForm: TConfigurationForm;
-
- implementation
-
- uses calend;
-
- {$R *.DFM}
-
- procedure TConfigurationForm.CloseBtnClick(Sender: TObject);
- begin
- SetConfig;
- Close;
- end;
-
- procedure TConfigurationForm.SetConfig;
- var
- dt : TDateTimePicker;
- begin
- dt := Form1.DateTimePicker1;
- if AlignmentRGrp.ItemIndex = 0 then
- dt.calAlignment := dtaLeft
- else dt.calAlignment := dtaRight;
- if DateFormatRGrp.ItemIndex = 0 then
- dt.DateFormat := dfShort
- else dt.DateFormat := dfLong;
- // Date Mode
- if DateModeCD.checked then
- dt.DateMode := dmComboBox
- else
- dt.DateMode := dmUpDown;
- // Colours
- with dt.CalColors do
- begin
- MonthBackColor := mbackcol;
- TextColor := textcol;
- TitleBackColor := titlebackcol;
- TitleTextColor := titletextcol;
- TrailingTextColor := trailcol;
- end;
- end;
-
-
- procedure TConfigurationForm.GetConfig;
- var
- dt : TDateTimePicker;
- begin
- dt := Form1.DateTimePicker1;
- if dt.calAlignment = dtaLeft then
- AlignmentRGrp.ItemIndex := 0
- else AlignmentRGrp.ItemIndex := 1;
- if dt.DateFormat = dfShort then
- DateFormatRGrp.ItemIndex := 0
- else DateFormatRGrp.ItemIndex := 1;
- // Date Mode
- if dt.DateMode = dmComboBox then
- DateModeCD.checked := true
- else
- DateModeCD.checked := false;
- // Colours
- with dt.CalColors do
- begin
- mbackcol := MonthBackColor;
- textcol := TextColor;
- titlebackcol := TitleBackColor;
- titletextcol := TitleTextColor;
- trailcol := TrailingTextColor;
- end;
- end;
-
- procedure TConfigurationForm.ApplyBtnClick(Sender: TObject);
- begin
- SetConfig;
- end;
-
- procedure TConfigurationForm.PickColourBtnClick(Sender: TObject);
- begin
- if ColorDialog1.Execute then
- begin
- if ComboBox1.Text = 'MonthBackColor' then
- mbackcol := ColorDialog1.Color
- else if ComboBox1.Text = 'TextColor' then
- textcol := ColorDialog1.Color
- else if ComboBox1.Text = 'TitleBackColor' then
- titlebackcol := ColorDialog1.Color
- else if ComboBox1.Text = 'TitleTextColor' then
- titletextcol := ColorDialog1.Color
- else if ComboBox1.Text = 'TrailingTextColor' then
- trailcol := ColorDialog1.Color
- else ShowMessage( 'The Combo Box does not contain a valid constant name!' );
- end;
- end;
-
- procedure TConfigurationForm.CancelBtnClick(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TConfigurationForm.FormShow(Sender: TObject);
- begin
- GetConfig;
- end;
-
- end.
-
-
-