home *** CD-ROM | disk | FTP | other *** search
- unit propunit;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- PWEdit: TEdit;
- PWBtn: TButton;
- RadioGroup1: TRadioGroup;
- NCRBtn: TRadioButton;
- LCRBtn: TRadioButton;
- UCRBtn: TRadioButton;
- GroupBox1: TGroupBox;
- ColorDialog1: TColorDialog;
- FGColourBtn: TButton;
- BGColourBtn: TButton;
- FontDialog1: TFontDialog;
- FontBtn: TButton;
- CheckBox1: TCheckBox;
- ShortHintBtn: TButton;
- LongHintBtn: TButton;
- HintLbl: TLabel;
- FancyHintBtn: TButton;
- procedure RadioGroup1Click(Sender: TObject);
- procedure RadioButtonCaseChangeClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FGColourBtnClick(Sender: TObject);
- procedure BGColourBtnClick(Sender: TObject);
- procedure FontBtnClick(Sender: TObject);
- procedure CheckBox1Click(Sender: TObject);
- procedure ShortHintBtnClick(Sender: TObject);
- procedure LongHintBtnClick(Sender: TObject);
- procedure PWBtnClick(Sender: TObject);
-
- private
- { Private declarations }
- public
- { Public declarations }
- procedure ShowHint( Sender : TObject );
- procedure FancyHint(var HintStr: string; var CanShow: Boolean;
- var HintInfo: THintInfo );
-
-
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
- procedure TForm1.FormCreate(Sender: TObject);
- // on Form Create, set various properties
- begin
- // set defaults for PWEdit
- with PWEdit do // =============== Set a few TEDIT Properties ======
- begin
- PasswordChar := #0; // #0 = no passwordchar
- CharCase := ecNormal;
- MaxLength := 10;
- Autosize := false;
- end;
- // Set check items on form
- RadioGroup1.ItemIndex := 0;
- NCRBtn.checked := true;
- // === HINTS ===
- // i) PWBtn
- PWBtn.Hint := 'Click to show password | You know it makes sense!';
- PWBtn.ShowHint := true;
- // ii) Application
- Application.HintColor := clYellow;
- Application.HintPause := 1000;
- Application.HintHidePause := 8000;
- // make ShowHint method the OnHint event-handler
- Application.OnHint := ShowHint;
- // make FancyHint method the OnShowHint event-handler
- Application.OnShowHint := FancyHint;
- // iii) LongHintBtn
- LongHintBtn.Hint := 'This'+#13#10+ 'is a'+#13#10+'multi-line'+#13#10+'hint | This is the long Hint Button';
- end;
-
- procedure TForm1.RadioGroup1Click(Sender: TObject);
- // toggle passwordchar
- begin
- if RadioGroup1.ItemIndex = 0 then
- PWEdit.PasswordChar := #0
- else PWEdit.PasswordChar := '*';
- end;
-
- procedure TForm1.RadioButtonCaseChangeClick(Sender: TObject);
- // toggle case
- begin
- if UCRBtn.Checked then PWEdit.CharCase := ecUpperCase
- else if LCRBtn.Checked then PWEdit.CharCase := ecLowerCase
- else PWEdit.CharCase := ecNormal;
- end;
-
- procedure TForm1.FGColourBtnClick(Sender: TObject);
- // pick a text colour
- begin
- if ColorDialog1.Execute then
- PWEdit.Font.Color := ColorDialog1.Color;
- end;
-
- procedure TForm1.BGColourBtnClick(Sender: TObject);
- // pick a background colour
- begin
- if ColorDialog1.Execute then
- PWEdit.Color := ColorDialog1.Color;
- end;
-
- procedure TForm1.FontBtnClick(Sender: TObject);
- // pick a font
- begin
- if FontDialog1.Execute then
- PWEdit.Font := FontDialog1.Font;
- end;
-
- procedure TForm1.CheckBox1Click(Sender: TObject);
- // Toggle Edit field's AutoSize property
- begin
- PWEdit.AutoSize := CheckBox1.Checked;
- end;
-
- procedure TForm1.ShowHint( Sender : TObject );
- // The OnHint event-handler
- begin
- // Display the Applications's Hint property in the form caption
- Caption := Application.Hint;
- end;
-
- procedure TForm1.FancyHint(var HintStr: string; var CanShow: Boolean;
- var HintInfo: THintInfo);
- begin
- if HintInfo.HintControl = FancyHintBtn then
- begin
- with HintInfo do
- begin
- HintColor := clFuchsia;
- HintMaxWidth := 30;
- Dec(HintPos.Y, FancyHintBtn.Height * 2 );
- Inc(HintPos.X, FancyHintBtn.Width );
- end;
- end;
- end;
-
- procedure TForm1.ShortHintBtnClick(Sender: TObject);
- begin
- HintLbl.Caption := GetShortHint(PWEdit.Hint);
- end;
-
- procedure TForm1.LongHintBtnClick(Sender: TObject);
- begin
- HintLbl.Caption := GetLongHint(PWEdit.Hint);
- end;
-
- procedure TForm1.PWBtnClick(Sender: TObject);
- begin
- RadioGroup1.ItemIndex := 0;
- end;
-
- end.
-
-