|
From: Peter T. <pe...@us...> - 2003-08-23 23:20:33
|
Update of /cvsroot/jvcl/dev/JVCL3/examples/JvValidateEdit
In directory sc8-pr-cvs1:/tmp/cvs-serv5637/JVCL3/examples/JvValidateEdit
Added Files:
JvCharStrEditor.dfm JvCharStrEditor.pas JvFormatEditDemo.dpr
JvFormatEditDemo.res MainFrm.dfm MainFrm.pas Notes.txt
readme.txt
Log Message:
- Copied jvcl/devtools and jvcl/examples dev/JVCL3
- Copied JVCLConvert *.dat files to dev/JVCL3/converter
--- NEW FILE: JvCharStrEditor.dfm ---
object frmJvCharEditDlg: TfrmJvCharEditDlg
Left = 365
Top = 180
Width = 535
Height = 417
ActiveControl = lvCharacters
BorderWidth = 2
Caption = 'TJvFormatEdit.Characters Editor'
Color = clBtnFace
Constraints.MinHeight = 175
Constraints.MinWidth = 320
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 345
Width = 523
Height = 41
Align = alBottom
BevelOuter = bvNone
TabOrder = 0
object btnOK: TButton
Left = 350
Top = 9
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = '&OK'
ModalResult = 1
TabOrder = 1
end
object btnCancel: TButton
Left = 438
Top = 9
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 2
end
object cbFonts: TComboBox
Left = 8
Top = 11
Width = 330
Height = 21
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
Sorted = True
TabOrder = 0
OnKeyPress = cbFontsKeyPress
end
end
object lvCharacters: TListView
Left = 0
Top = 0
Width = 523
Height = 345
Align = alClient
Checkboxes = True
Columns = <
item
AutoSize = True
Caption = 'Characters'
end>
ColumnClick = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
HideSelection = False
IconOptions.AutoArrange = True
LargeImages = ImageList1
MultiSelect = True
ReadOnly = True
ParentFont = False
ParentShowHint = False
PopupMenu = PopupMenu1
ShowHint = True
SmallImages = ImageList1
TabOrder = 1
ViewStyle = vsList
OnAdvancedCustomDrawItem = lvCharactersAdvancedCustomDrawItem
OnEnter = lvCharactersEnter
OnInfoTip = lvCharactersInfoTip
OnResize = lvCharactersResize
OnSelectItem = lvCharactersSelectItem
end
object PopupMenu1: TPopupMenu
Left = 16
Top = 16
object SelectAll1: TMenuItem
Action = acCheckAll
end
object UnselectAll1: TMenuItem
Action = acUnCheckAll
end
object N2: TMenuItem
Caption = '-'
end
object CheckSelected1: TMenuItem
Action = acCheckSel
end
object UnCheckSelected1: TMenuItem
Action = acUnCheckSel
end
object N3: TMenuItem
Caption = '-'
end
object Special1: TMenuItem
Caption = 'Check Special'
object Alpha1: TMenuItem
Action = acAlpha
end
object acInteger1: TMenuItem
Action = acInteger
end
object acAlphaNum1: TMenuItem
Action = acAlphaNum
end
object acHex1: TMenuItem
Action = acHex
end
object acFloat1: TMenuItem
Action = acFloat
end
object acScientific1: TMenuItem
Action = acScientific
end
object acCurrency1: TMenuItem
Action = acCurrency
end
end
object Invertselection1: TMenuItem
Action = acInvertCheck
end
object N4: TMenuItem
Caption = '-'
end
object View1: TMenuItem
Caption = 'View'
object Large1: TMenuItem
Action = acLarge
GroupIndex = 1
RadioItem = True
end
object Small1: TMenuItem
Action = acSmall
GroupIndex = 1
RadioItem = True
end
object List1: TMenuItem
Action = acList
GroupIndex = 1
RadioItem = True
end
object Report1: TMenuItem
Action = acReport
GroupIndex = 1
RadioItem = True
end
end
end
object ActionList1: TActionList
Left = 48
Top = 16
object acCheckAll: TAction
Category = 'General'
Caption = 'Check All'
OnExecute = acCheckAllExecute
end
object acUnCheckAll: TAction
Category = 'General'
Caption = 'Uncheck All'
OnExecute = acUnCheckAllExecute
end
object acInvertCheck: TAction
Category = 'General'
Caption = 'Invert Checks'
OnExecute = acInvertCheckExecute
end
object acAlpha: TAction
Category = 'Special'
Caption = 'Alphabetic'
OnExecute = acAlphaExecute
end
object acAlphaNum: TAction
Category = 'Special'
Caption = 'Alpha Numeric'
OnExecute = acAlphaNumExecute
end
object acHex: TAction
Category = 'Special'
Caption = 'Hexadecimal'
OnExecute = acHexExecute
end
object acFloat: TAction
Category = 'Special'
Caption = 'Float'
OnExecute = acFloatExecute
end
object acScientific: TAction
Category = 'Special'
Caption = 'Scientific'
OnExecute = acScientificExecute
end
object acCurrency: TAction
Category = 'Special'
Caption = 'Currency'
OnExecute = acCurrencyExecute
end
object acInteger: TAction
Category = 'Special'
Caption = 'Integer'
OnExecute = acIntegerExecute
end
object acLarge: TAction
Caption = 'Large'
OnExecute = acLargeExecute
end
object acSmall: TAction
Caption = 'Small'
OnExecute = acSmallExecute
end
object acList: TAction
Caption = 'List'
Checked = True
OnExecute = acListExecute
end
object acReport: TAction
Caption = 'Report'
OnExecute = acReportExecute
end
object acCheckSel: TAction
Category = 'General'
Caption = 'Check Selected'
OnExecute = acCheckSelExecute
end
object acUnCheckSel: TAction
Category = 'General'
Caption = 'Uncheck Selected'
OnExecute = acUnCheckSelExecute
end
end
object ImageList1: TImageList
Left = 80
Top = 16
end
end
--- NEW FILE: JvCharStrEditor.pas ---
{$I JVCL.INC}
unit JvCharStrEditor;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls, Menus, ActnList, ImgList;
type
TfrmJvCharEditDlg = class(TForm)
Panel1: TPanel;
btnOK: TButton;
btnCancel: TButton;
lvCharacters: TListView;
PopupMenu1: TPopupMenu;
SelectAll1: TMenuItem;
UnselectAll1: TMenuItem;
Invertselection1: TMenuItem;
ActionList1: TActionList;
acCheckAll: TAction;
acUnCheckAll: TAction;
acInvertCheck: TAction;
acAlpha: TAction;
acAlphaNum: TAction;
acHex: TAction;
acFloat: TAction;
acScientific: TAction;
acCurrency: TAction;
acInteger: TAction;
Special1: TMenuItem;
Alpha1: TMenuItem;
acAlphaNum1: TMenuItem;
acInteger1: TMenuItem;
acFloat1: TMenuItem;
acHex1: TMenuItem;
acScientific1: TMenuItem;
acCurrency1: TMenuItem;
acLarge: TAction;
acSmall: TAction;
acList: TAction;
acReport: TAction;
View1: TMenuItem;
Large1: TMenuItem;
Small1: TMenuItem;
List1: TMenuItem;
Report1: TMenuItem;
ImageList1: TImageList;
acCheckSel: TAction;
acUnCheckSel: TAction;
CheckSelected1: TMenuItem;
UnCheckSelected1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
cbFonts: TComboBox;
procedure FormCreate(Sender: TObject);
procedure lvCharactersInfoTip(Sender: TObject; Item: TListItem;
var InfoTip: string);
procedure acInvertCheckExecute(Sender: TObject);
procedure acUnCheckAllExecute(Sender: TObject);
procedure acCheckAllExecute(Sender: TObject);
procedure acAlphaExecute(Sender: TObject);
procedure acAlphaNumExecute(Sender: TObject);
procedure acHexExecute(Sender: TObject);
procedure acFloatExecute(Sender: TObject);
procedure acScientificExecute(Sender: TObject);
procedure acCurrencyExecute(Sender: TObject);
procedure acIntegerExecute(Sender: TObject);
procedure acLargeExecute(Sender: TObject);
procedure acSmallExecute(Sender: TObject);
procedure acListExecute(Sender: TObject);
procedure acReportExecute(Sender: TObject);
procedure lvCharactersResize(Sender: TObject);
procedure acCheckSelExecute(Sender: TObject);
procedure acUnCheckSelExecute(Sender: TObject);
procedure lvCharactersEnter(Sender: TObject);
procedure cbFontsCloseUp(Sender: TObject);
procedure cbFontsKeyPress(Sender: TObject; var Key: Char);
procedure lvCharactersAdvancedCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
var DefaultDraw: Boolean);
procedure lvCharactersSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
private
function getCharacters: string;
procedure setCharacters(const Value: string);
procedure UnCheckAll;
{ Private declarations }
public
{ Public declarations }
class function Edit(var Characters: string): boolean;
property Characters: string read getCharacters write setCharacters;
end;
const
cAsciiNames:array [char] of PChar =
(
'NUL', // null
'SOH', // start of heading
'STX', // start of text
'ETX', // end of text
'EOT', // end of transmission
'ENQ', // enquiry
'ACK', // acknowledge
'BEL', // bell
'BS', // backspace
'TAB', // horizontal tab
'LF', // line feed
'VT', // vertical tab
'FF', // form feed
'CR', // carriage return
'SO', // shift out
'SI', // shift in
'DLE', // data link escape
'DC1', // device control 1
'DC2', // device control 2
'DC3', // device control 3
'DC4', // device control 4
'NAK', // negative acknowledge
'SYN', // synch idle
'ETB', // end of trans. block
'CAN', // cancel
'EM', // end of medium
'SUB', // substitute
'ESC', // escape
'FS', // file separator
'GS', // group separator
'RS', // record separator
'US', // unit separator
'SPACE', // space
#33, #34, #35, #36, #37, #38, #39,
#40, #41, #42, #43, #44, #45, #46, #47, #48, #49,
#50, #51, #52, #53, #54, #55, #56, #57, #58, #59,
#60, #61, #62, #63, #64, #65, #66, #67, #68, #69,
#70, #71, #72, #73, #74, #75, #76, #77, #78, #79,
#80, #81, #82, #83, #84, #85, #86, #87, #88, #89,
#90, #91, #92, #93, #94, #95, #96, #97, #98, #99,
#100,#101,#102,#103,#104,#105,#106,#107,#108,#109,
#110,#111,#112,#113,#114,#115,#116,#117,#118,#119,
#120,#121,#122,#123,#124,#125,#126,#127,#128,#129,
#130,#131,#132,#133,#134,#135,#136,#137,#138,#139,
#140,#141,#142,#143,#144,#145,#146,#147,#148,#149,
#150,#151,#152,#153,#154,#155,#156,#157,#158,#159,
#160,#161,#162,#163,#164,#165,#166,#167,#168,#169,
#170,#171,#172,#173,#174,#175,#176,#177,#178,#179,
#180,#181,#182,#183,#184,#185,#186,#187,#188,#189,
#190,#191,#192,#193,#194,#195,#196,#197,#198,#199,
#200,#201,#202,#203,#204,#205,#206,#207,#208,#209,
#210,#211,#212,#213,#214,#215,#216,#217,#218,#219,
#220,#221,#222,#223,#224,#225,#226,#227,#228,#229,
#230,#231,#232,#233,#234,#235,#236,#237,#238,#239,
#240,#241,#242,#243,#244,#245,#246,#247,#248,#249,
#250,#251,#252,#253,#254,#255);
// converts a syschar set to it's textual display representation
// as is displayed in the OI, f ex
// NOTE: this is *not* the opposite of StringToSysCharSet below!
function SysCharSetToString(ASet:TSysCharSet;Brackets:boolean):string;
// converts a string to a SysCharSet
function StringToSysCharSet(const S:string):TSysCharSet;
// returns either an unquoted name, like NUL, or a quoted character, like 'A'
function GetCharName(const Ch:char):string;
resourcestring
SFormCaption = 'TJvFormatEdit.Characters Editor ($%.2x, #%.2u, "%s")';
implementation
{$R *.DFM}
function StringToSysCharSet(const S:string):TSysCharSet;
var i:integer;
begin
Result := [];
for i := 1 to Length(S) do
begin
Include(Result,S[i]);
if Result = [#0..#255] then Exit; // everything included, so no need to continue
end;
end;
function GetCharName(const Ch:char):string;
var FTmpType:word;
begin
Result := cAsciiNames[Ch];
GetStringTypeEx(LOCALE_USER_DEFAULT,CT_CTYPE1,@Ch,1,FTmpType);
if (FTmpType and C1_CNTRL = 0) and (Ch <> #32) then
Result := #39 + Result + #39;
end;
// far from perfect, but kind of works...
function SysCharSetToString(ASet:TSysCharSet;Brackets:boolean):string;
var i,LastChar,PrevChar:char;
begin
PrevChar := #255;
LastChar := #0;
for i := #0 to #255 do
begin
if i in ASet then
begin
// if PrevChar = #0 then
if Ord(i)-Ord(PrevChar) <> 1 then
begin
if Result <> '' then
Result := Result + ',' + getCharName(i)
else
Result := getCharName(i);
LastChar := i;
end
else if i = #255 then
begin
if Result = '' then
Result := GetCharName(i)
else if Ord(i) - Ord(LastChar) > 1 then
Result := Result + '...' + GetCharName(i)
else
Result := Result + ',' + GetCharName(i);
Break;
end;
PrevChar := i;
end
else
begin
if Ord(i) - Ord(LastChar) > 1 then
Result := Result + '...' + GetCharName(Pred(i))
else if (LastChar = #0) and (Pred(i) <> LastChar) and (i <> #0) then
Result := Result + ',' + GetCharName(Pred(i));
PrevChar := #255;
LastChar := i;
end;
end;
if (Length(Result) > 0) and (AnsiLastChar(Result) = ',') then
SetLength(Result,Length(Result)-1);
if Brackets then
Result := '[' + Result + ']';
end;
{ TfrmJvCharEditDlg }
class function TfrmJvCharEditDlg.Edit(
var Characters: string): boolean;
var
frmJvCharEditDlg: TfrmJvCharEditDlg;
begin
frmJvCharEditDlg := self.Create(Application);
try
frmJvCharEditDlg.Characters := Characters;
Result := frmJvCharEditDlg.ShowModal = mrOK;
if Result then
Characters := frmJvCharEditDlg.Characters;
finally
frmJvCharEditDlg.Free;
end;
end;
function TfrmJvCharEditDlg.getCharacters: string;
var i: integer;
begin
Result := '';
with lvCharacters do
for i := 0 to Items.Count - 1 do
if Items[i].Checked then
Result := Result + Char(Items[i].Data);
end;
procedure TfrmJvCharEditDlg.setCharacters(const Value: string);
var i: integer;
begin
acUnCheckAll.Execute;
with lvCharacters do
for i := 1 to Length(Value) do
Items[Ord(Value[i])].Checked := true;
end;
procedure TfrmJvCharEditDlg.FormCreate(Sender: TObject);
var i: char;j:integer;
begin
with lvCharacters do
begin
Items.BeginUpdate;
try
Items.Clear;
for i := #0 to #255 do
with Items.Add do
begin
Caption := Format('%s', [cAsciiNames[i]]);
Data := Pointer(i);
end;
finally
Items.EndUpdate;
end;
end;
cbFonts.Items := Screen.Fonts;
j := cbFonts.Items.IndexOf(Font.Name);
if j = -1 then
cbFonts.ItemIndex := cbFonts.Items.Add(Font.Name)
else
cbFonts.ItemIndex := j;
Caption := Format(SFormCaption,[0,0,cAsciiNames[#0]]);
end;
procedure TfrmJvCharEditDlg.lvCharactersInfoTip(Sender: TObject;
Item: TListItem; var InfoTip: string);
begin
if Item <> nil then
InfoTip := Format('$%.2x, #%.2d, "%s"', [integer(Item.Data), integer(Item.Data),cAsciiNames[Char(Item.Data)]]);
end;
procedure TfrmJvCharEditDlg.acInvertCheckExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := not Items[i].Checked;
end;
procedure TfrmJvCharEditDlg.acUnCheckAllExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := false;
end;
procedure TfrmJvCharEditDlg.acCheckAllExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := true;
end;
procedure TfrmJvCharEditDlg.acAlphaExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := IsCharAlpha(char(Items[i].Data));
end;
procedure TfrmJvCharEditDlg.acAlphaNumExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := IsCharAlphaNumeric(char(Items[i].Data));
end;
procedure TfrmJvCharEditDlg.acHexExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := char(Items[i].Data) in ['0'..'9', 'A'..'F', 'a'..'f'];
end;
procedure TfrmJvCharEditDlg.acFloatExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := (char(Items[i].Data) in ['0'..'9', '-','+', DecimalSeparator]);
end;
procedure TfrmJvCharEditDlg.acScientificExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := (char(Items[i].Data) in ['0'..'9', 'E','e','-','+', DecimalSeparator]);
end;
procedure TfrmJvCharEditDlg.acCurrencyExecute(Sender: TObject);
begin
acFloat.Execute;
end;
procedure TfrmJvCharEditDlg.acIntegerExecute(Sender: TObject);
var i: integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
Items[i].Checked := (char(Items[i].Data) in ['0'..'9', '-','+']);
end;
procedure TfrmJvCharEditDlg.UnCheckAll;
begin
acLarge.Checked := false;
acSmall.Checked := false;
acList.Checked := false;
acReport.Checked := false;
end;
procedure TfrmJvCharEditDlg.acLargeExecute(Sender: TObject);
begin
UnCheckAll;
acLarge.Checked := true;
lvCharacters.ViewStyle := vsIcon;
end;
procedure TfrmJvCharEditDlg.acSmallExecute(Sender: TObject);
begin
UnCheckAll;
acSmall.Checked := true;
lvCharacters.ViewStyle := vsSmallIcon;
end;
procedure TfrmJvCharEditDlg.acListExecute(Sender: TObject);
begin
UnCheckAll;
acList.Checked := true;
lvCharacters.ViewStyle := vsList;
end;
procedure TfrmJvCharEditDlg.acReportExecute(Sender: TObject);
begin
UnCheckAll;
acReport.Checked := true;
lvCharacters.ViewStyle := vsReport;
lvCharacters.Columns[0].Width := -2;
end;
procedure TfrmJvCharEditDlg.lvCharactersResize(Sender: TObject);
begin
lvCharacters.Columns[0].Width := -2;
end;
procedure TfrmJvCharEditDlg.acCheckSelExecute(Sender: TObject);
var i:integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
if Items[i].Selected then
Items[i].Checked := true;
end;
procedure TfrmJvCharEditDlg.acUnCheckSelExecute(Sender: TObject);
var i:integer;
begin
with lvCharacters do
for i := 0 to Items.Count - 1 do
if Items[i].Selected then
Items[i].Checked := false;
end;
procedure TfrmJvCharEditDlg.lvCharactersEnter(Sender: TObject);
begin
if lvCharacters.Selected = nil then
lvCharacters.Selected := lvCharacters.Items[0];
lvCharacters.Selected.Focused := true;
end;
procedure TfrmJvCharEditDlg.cbFontsCloseUp(Sender: TObject);
begin
lvCharacters.Font.Name := cbFonts.Text;
end;
procedure TfrmJvCharEditDlg.cbFontsKeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13 then
cbFontsCloseUp(Sender);
end;
procedure TfrmJvCharEditDlg.lvCharactersAdvancedCustomDrawItem(
Sender: TCustomListView; Item: TListItem; State: TCustomDrawState;
Stage: TCustomDrawStage; var DefaultDraw: Boolean);
begin
DefaultDraw := true;
if Item.Checked then
begin
lvCharacters.Canvas.Font.Style := [fsBold];
lvCharacters.Canvas.Font.Color := clWhite;
lvCharacters.Canvas.Brush.Color := clMaroon;
end;
end;
procedure TfrmJvCharEditDlg.lvCharactersSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
if Item <> nil then
Caption := Format(SFormCaption,[integer(Item.Data),integer(Item.Data),cAsciiNames[Char(Item.Data)]]);
end;
end.
--- NEW FILE: JvFormatEditDemo.dpr ---
program JvFormatEditDemo;
uses
Forms,
MainFrm in 'MainFrm.pas' {frmValidateEditDemo};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TfrmValidateEditDemo, frmValidateEditDemo);
Application.Run;
end.
--- NEW FILE: JvFormatEditDemo.res ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: MainFrm.dfm ---
object frmValidateEditDemo: TfrmValidateEditDemo
Left = 304
Top = 186
BorderStyle = bsDialog
Caption = 'JvValidateEdit Demo'
ClientHeight = 402
ClientWidth = 384
Color = clBtnFace
Constraints.MinHeight = 170
Constraints.MinWidth = 325
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label2: TLabel
Left = 8
Top = 248
Width = 63
Height = 13
Caption = 'Validate Edit:'
end
object GroupBox1: TGroupBox
Left = 8
Top = 8
Width = 369
Height = 233
Caption = 'Properties'
TabOrder = 0
object Label1: TLabel
Left = 8
Top = 16
Width = 75
Height = 13
Caption = 'Display Format:'
end
object Label3: TLabel
Left = 8
Top = 112
Width = 64
Height = 13
Caption = 'Check Chars:'
end
object Label4: TLabel
Left = 232
Top = 88
Width = 69
Height = 13
Caption = 'Decimal Places'
end
object Label6: TLabel
Left = 8
Top = 64
Width = 65
Height = 13
Caption = 'Display Prefix'
end
object Label7: TLabel
Left = 8
Top = 88
Width = 65
Height = 13
Caption = 'Display Suffix'
end
object cbDisplayFormat: TComboBox
Left = 8
Top = 32
Width = 193
Height = 21
Style = csDropDownList
ItemHeight = 13
TabOrder = 0
OnChange = cbDisplayFormatChange
OnKeyPress = cbDisplayFormatKeyPress
end
object Button2: TButton
Left = 336
Top = 8
Width = 21
Height = 21
Anchors = [akTop, akRight]
Caption = '...'
TabOrder = 1
Visible = False
end
object chkHasMaxValue: TCheckBox
Left = 216
Top = 40
Width = 89
Height = 17
Caption = 'Has Maximum'
TabOrder = 2
OnClick = chkHasMaxValueClick
end
object chkHasMinValue: TCheckBox
Left = 216
Top = 64
Width = 89
Height = 17
Caption = 'Has Minimum'
TabOrder = 3
OnClick = chkHasMinValueClick
end
object seDecimalPlaces: TSpinEdit
Left = 312
Top = 88
Width = 49
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 4
Value = 0
OnChange = seDecimalPlacesChange
end
object chkZeroEmpty: TCheckBox
Left = 216
Top = 16
Width = 97
Height = 17
Caption = 'Empty if Zero?'
TabOrder = 5
OnClick = chkZeroEmptyClick
end
object edCheckChars: TEdit
Left = 8
Top = 128
Width = 297
Height = 21
TabOrder = 6
end
object btnCheckChars: TButton
Left = 312
Top = 128
Width = 49
Height = 21
Caption = 'Set'
TabOrder = 7
OnClick = btnCheckCharsClick
end
object edDisplayPrefix: TEdit
Left = 88
Top = 64
Width = 57
Height = 21
TabOrder = 8
end
object edDisplaySuffix: TEdit
Left = 88
Top = 88
Width = 57
Height = 21
TabOrder = 9
end
object btnSetDisplayPrefix: TButton
Left = 152
Top = 64
Width = 47
Height = 21
Caption = 'Set'
TabOrder = 10
OnClick = btnSetDisplayPrefixClick
end
object btnSetDisplaySuffix: TButton
Left = 152
Top = 88
Width = 47
Height = 21
Caption = 'Set'
TabOrder = 11
OnClick = btnSetDisplaySuffixClick
end
object edMaxValue: TEdit
Left = 312
Top = 40
Width = 49
Height = 21
TabOrder = 12
OnExit = edMaxValueExit
end
object edMinValue: TEdit
Left = 312
Top = 64
Width = 49
Height = 21
TabOrder = 13
OnExit = edMinValueExit
end
object GroupBox3: TGroupBox
Left = 8
Top = 152
Width = 353
Height = 73
Caption = 'Critical Points'
TabOrder = 14
object Label8: TLabel
Left = 104
Top = 16
Width = 31
Height = 13
Caption = 'Above'
end
object Label9: TLabel
Left = 200
Top = 16
Width = 31
Height = 13
Caption = 'Colour'
end
object Label10: TLabel
Left = 104
Top = 40
Width = 28
Height = 13
Caption = 'Below'
end
object Label11: TLabel
Left = 200
Top = 40
Width = 31
Height = 13
Caption = 'Colour'
end
object Label12: TLabel
Left = 8
Top = 24
Width = 65
Height = 13
Caption = 'Check Points:'
end
object edCPMaxValue: TEdit
Left = 144
Top = 16
Width = 49
Height = 21
TabOrder = 0
OnExit = edCPMaxValueExit
end
object colCPAbove: TJvColorComboBox
Left = 240
Top = 16
Width = 105
Height = 20
ColorNameMap.Strings = (
'clBlack=Black'
'clMaroon=Maroon'
'clGreen=Green'
'clOlive=Olive'
'clNavy=Navy'
'clPurple=Purple'
'clTeal=Teal'
'clGray=Gray'
'clSilver=Silver'
'clRed=Red'
'clLime=Lime'
'clYellow=Yellow'
'clBlue=Blue'
'clFuchsia=Fuchsia'
'clAqua=Aqua'
'clLtGray=Light Gray'
'clDkGray=Dark Gray'
'clWhite=White'
'clMoneyGreen=Money Green'
'clSkyBlue=Sky Blue'
'clCream=Cream'
'clMedGray=Medium Gray'
'clScrollBar=ScrollBar'
'clBackground=Background'
'clActiveCaption=Active Caption'
'clInactiveCaption=Inactive Caption'
'clMenu=Menu'
'clWindow=Window'
'clWindowFrame=Window Frame'
'clMenuText=Menu Text'
'clWindowText=Window Text'
'clCaptionText=Caption Text'
'clActiveBorder=Active Border'
'clInactiveBorder=Inactive Border'
'clAppWorkSpace=Application Workspace'
'clHighlight=Highlight'
'clHighlightText=Highlight Text'
'clBtnFace=Button Face'
'clBtnShadow=Button Shadow'
'clGrayText=Gray Text'
'clBtnText=Button Text'
'clInactiveCaptionText=Inactive Caption Text'
'clBtnHighlight=Button Highlight'
'cl3DDkShadow=3D Dark Shadow'
'cl3DLight=3D Light'
'clInfoText=Info Text'
'clInfoBk=Info Background'
'clHotLight=Hot Light'
'clGradientActiveCaption=Gradient Active Caption'
'clGradientInactiveCaption=Gradient Inactive Caption'
'clMenuHighlight=Menu Highlight'
'clMenuBar=MenuBar'
'clNone=None'
'clDefault=Default')
ColorDialogText = '(Other...)'
NewColorText = 'Custom'
DroppedDownWidth = 105
TabOrder = 1
end
object edCPMinValue: TEdit
Left = 144
Top = 40
Width = 49
Height = 21
TabOrder = 2
OnExit = edCPMinValueExit
end
object colCPBelow: TJvColorComboBox
Left = 240
Top = 40
Width = 105
Height = 20
ColorNameMap.Strings = (
'clBlack=Black'
'clMaroon=Maroon'
'clGreen=Green'
'clOlive=Olive'
'clNavy=Navy'
'clPurple=Purple'
'clTeal=Teal'
'clGray=Gray'
'clSilver=Silver'
'clRed=Red'
'clLime=Lime'
'clYellow=Yellow'
'clBlue=Blue'
'clFuchsia=Fuchsia'
'clAqua=Aqua'
'clLtGray=Light Gray'
'clDkGray=Dark Gray'
'clWhite=White'
'clMoneyGreen=Money Green'
'clSkyBlue=Sky Blue'
'clCream=Cream'
'clMedGray=Medium Gray'
'clScrollBar=ScrollBar'
'clBackground=Background'
'clActiveCaption=Active Caption'
'clInactiveCaption=Inactive Caption'
'clMenu=Menu'
'clWindow=Window'
'clWindowFrame=Window Frame'
'clMenuText=Menu Text'
'clWindowText=Window Text'
'clCaptionText=Caption Text'
'clActiveBorder=Active Border'
'clInactiveBorder=Inactive Border'
'clAppWorkSpace=Application Workspace'
'clHighlight=Highlight'
'clHighlightText=Highlight Text'
'clBtnFace=Button Face'
'clBtnShadow=Button Shadow'
'clGrayText=Gray Text'
'clBtnText=Button Text'
'clInactiveCaptionText=Inactive Caption Text'
'clBtnHighlight=Button Highlight'
'cl3DDkShadow=3D Dark Shadow'
'cl3DLight=3D Light'
'clInfoText=Info Text'
'clInfoBk=Info Background'
'clHotLight=Hot Light'
'clGradientActiveCaption=Gradient Active Caption'
'clGradientInactiveCaption=Gradient Inactive Caption'
'clMenuHighlight=Menu Highlight'
'clMenuBar=MenuBar'
'clNone=None'
'clDefault=Default')
ColorDialogText = '(Other...)'
NewColorText = 'Custom'
DroppedDownWidth = 105
TabOrder = 3
end
object cbCPCheckPoints: TComboBox
Left = 8
Top = 40
Width = 89
Height = 21
Style = csDropDownList
ItemHeight = 13
TabOrder = 4
OnChange = cbCPCheckPointsChange
end
end
end
object GroupBox2: TGroupBox
Left = 8
Top = 296
Width = 369
Height = 97
Caption = 'Set To'
TabOrder = 1
object Label5: TLabel
Left = 8
Top = 16
Width = 26
Height = 13
Caption = 'Value'
end
object edSetTo: TEdit
Left = 48
Top = 16
Width = 121
Height = 21
TabOrder = 0
end
object rgSetToType: TRadioGroup
Left = 8
Top = 40
Width = 353
Height = 49
Caption = 'as Type'
Columns = 4
ItemIndex = 3
Items.Strings = (
'Currency'
'Float'
'Integer'
'Text')
TabOrder = 1
end
object btnSetTo: TButton
Left = 176
Top = 16
Width = 75
Height = 21
Caption = 'Set'
Default = True
TabOrder = 2
OnClick = btnSetToClick
end
object chkAsVariant: TCheckBox
Left = 256
Top = 16
Width = 97
Height = 17
Caption = 'as Variant'
TabOrder = 3
end
end
object chkValueChanged: TCheckBox
Left = 224
Top = 248
Width = 153
Height = 17
Caption = 'Message on Value Change?'
TabOrder = 2
end
end
--- NEW FILE: MainFrm.pas ---
{
A demo for the JvValidateEdit component. You don't need to install the component
to run this demo, but the JvValidateEdit and the JvCharStrEditor units
must be in the same directory.
}
unit MainFrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
JvValidateEdit, StdCtrls, ComCtrls, Spin, ExtCtrls, JvCombobox,
JvColorCombo;
type
TfrmValidateEditDemo = class(TForm)
Label2: TLabel;
GroupBox1: TGroupBox;
Label1: TLabel;
Label3: TLabel;
cbDisplayFormat: TComboBox;
Button2: TButton;
chkHasMaxValue: TCheckBox;
chkHasMinValue: TCheckBox;
seDecimalPlaces: TSpinEdit;
Label4: TLabel;
chkZeroEmpty: TCheckBox;
edCheckChars: TEdit;
GroupBox2: TGroupBox;
Label5: TLabel;
edSetTo: TEdit;
rgSetToType: TRadioGroup;
btnSetTo: TButton;
chkValueChanged: TCheckBox;
btnCheckChars: TButton;
Label6: TLabel;
Label7: TLabel;
edDisplayPrefix: TEdit;
edDisplaySuffix: TEdit;
btnSetDisplayPrefix: TButton;
btnSetDisplaySuffix: TButton;
edMaxValue: TEdit;
edMinValue: TEdit;
GroupBox3: TGroupBox;
Label8: TLabel;
edCPMaxValue: TEdit;
Label9: TLabel;
colCPAbove: TJvColorComboBox;
Label10: TLabel;
edCPMinValue: TEdit;
Label11: TLabel;
colCPBelow: TJvColorComboBox;
Label12: TLabel;
cbCPCheckPoints: TComboBox;
chkAsVariant: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure cbDisplayFormatKeyPress(Sender: TObject; var Key: Char);
procedure cbDisplayFormatChange(Sender: TObject);
procedure seDecimalPlacesChange(Sender: TObject);
procedure chkHasMaxValueClick(Sender: TObject);
procedure chkHasMinValueClick(Sender: TObject);
procedure btnSetToClick(Sender: TObject);
procedure chkZeroEmptyClick(Sender: TObject);
procedure btnCheckCharsClick(Sender: TObject);
procedure btnSetDisplayPrefixClick(Sender: TObject);
procedure btnSetDisplaySuffixClick(Sender: TObject);
procedure edCPMaxValueExit(Sender: TObject);
procedure edCPMinValueExit(Sender: TObject);
procedure colCPAboveChange(Sender: TObject);
procedure colCPBelowChange(Sender: TObject);
procedure cbCPCheckPointsChange(Sender: TObject);
procedure edMaxValueExit(Sender: TObject);
procedure edMinValueExit(Sender: TObject);
private
procedure DoCustomValidate(Sender: TObject; Key: Char;
const AText: string; const Pos: Integer; var IsValid: boolean);
procedure ShowValueChange(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
FValidateEdit: TJvValidateEdit;
end;
var
frmValidateEditDemo: TfrmValidateEditDemo;
implementation
uses
TypInfo,
JvFunctions; // for D5
{$R *.DFM}
procedure TfrmValidateEditDemo.DoCustomValidate(Sender: TObject; Key: Char;
const AText: string; const Pos: Integer; var IsValid: boolean);
function KeyOrAscii(Key: Char): string;
begin
if Key < #32 then
Result := Format('#%s', [Key])
else
Result := Key;
end;
begin
IsValid := MessageBox(Handle, PChar(Format('Accept this key: %s?', [KeyOrAscii(Key)])), PChar('Validate'), MB_YESNO) = IDYES;
end;
procedure TfrmValidateEditDemo.FormCreate(Sender: TObject);
var
df: TJvValidateEditDisplayFormat;
cp: TJvValidateEditCriticalPointsCheck;
begin
FValidateEdit := TJvValidateEdit.Create(self);
FValidateEdit.Parent := Self;
FValidateEdit.SetBounds(Label2.Left, Label2.Top + Label2.Height + 4, Self.ClientWidth - Label2.Left * 2, FValidateEdit.Height);
FValidateEdit.Anchors := [akLeft, akTop, akRight];
FValidateEdit.OnCustomValidate := DoCustomValidate;
FValidateEdit.OnValueChanged := ShowValueChange;
for df := Low(TJvValidateEditDisplayFormat) to High(TJvValidateEditDisplayFormat) do
cbDisplayFormat.Items.Add(GetEnumName(TypeInfo(TJvValidateEditDisplayFormat), Ord(df)));
cbDisplayFormat.ItemIndex := 0;
cbDisplayFormatChange(Self);
for cp := Low(TJvValidateEditCriticalPointsCheck) to High(TJvValidateEditCriticalPointsCheck) do
cbCPCheckPoints.Items.Add(GetEnumName(TypeInfo(TJvValidateEditCriticalPointsCheck), Ord(cp)));
cbCPCheckPoints.ItemIndex := 0;
edCPMaxValue.Text := FloatToStr(FValidateEdit.CriticalPoints.MaxValue);
colCPAbove.ColorValue := FValidateEdit.CriticalPoints.ColorAbove;
edCPMinValue.Text := FloatToStr(FValidateEdit.CriticalPoints.MinValue);
colCPBelow.ColorValue := FValidateEdit.CriticalPoints.ColorBelow;
colCPAbove.OnChange := colCPAboveChange;
colCPBelow.OnChange := colCPBelowChange;
end;
procedure TfrmValidateEditDemo.cbDisplayFormatKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
cbDisplayFormatChange(Sender);
end;
procedure TfrmValidateEditDemo.cbDisplayFormatChange(Sender: TObject);
begin
FValidateEdit.DisplayFormat := TJvValidateEditDisplayFormat(cbDisplayFormat.ItemIndex);
edCheckChars.Text := FValidateEdit.CheckChars;
btnCheckChars.Enabled := (cbDisplayFormat.Text = 'dfCheckChars') or
(cbDisplayFormat.Text = 'dfNonCheckChars');
end;
procedure TfrmValidateEditDemo.seDecimalPlacesChange(Sender: TObject);
begin
FValidateEdit.DecimalPlaces := seDecimalPlaces.Value;
end;
procedure TfrmValidateEditDemo.chkHasMaxValueClick(Sender: TObject);
begin
FValidateEdit.MaxValue := StrToFloatDef(edMaxValue.Text, 0);
FValidateEdit.HasMaxValue := chkHasMaxValue.Checked;
end;
procedure TfrmValidateEditDemo.chkHasMinValueClick(Sender: TObject);
begin
FValidateEdit.MinValue := StrToFloatDef(edMinValue.Text, 0);
FValidateEdit.HasMinValue := chkHasMinValue.Checked;
end;
procedure TfrmValidateEditDemo.btnSetToClick(Sender: TObject);
begin
case rgSetToType.ItemIndex of
0:
if chkAsVariant.Checked then
FValidateEdit.Value := StrToCurrDef(edSetTo.Text, 0)
else
FValidateEdit.AsCurrency := StrToCurrDef(edSetTo.Text, 0);
1:
if chkAsVariant.Checked then
FValidateEdit.Value := StrToFloatDef(edSetTo.Text, 0)
else
FValidateEdit.AsFloat := StrToFloatDef(edSetTo.Text, 0);
2:
if chkAsVariant.Checked then
FValidateEdit.Value := StrToIntDef(edSetTo.Text, 0)
else
FValidateEdit.AsInteger := StrToIntDef(edSetTo.Text, 0);
3:
if chkAsVariant.Checked then
FValidateEdit.Value := edSetTo.Text
else
FValidateEdit.Text := edSetTo.Text;
end;
edSetTo.SetFocus;
end;
procedure TfrmValidateEditDemo.ShowValueChange(Sender: TObject);
begin
if chkValueChanged.Checked then
MessageDlg('ValidateEdit Text changed to: ' + FValidateEdit.Text,
mtInformation, [mbOK], 0);
end;
procedure TfrmValidateEditDemo.chkZeroEmptyClick(Sender: TObject);
begin
FValidateEdit.ZeroEmpty := chkZeroEmpty.Checked;
end;
procedure TfrmValidateEditDemo.btnCheckCharsClick(Sender: TObject);
begin
FValidateEdit.CheckChars := edCheckChars.Text;
end;
procedure TfrmValidateEditDemo.btnSetDisplayPrefixClick(Sender: TObject);
begin
FValidateEdit.DisplayPrefix := edDisplayPrefix.Text;
end;
procedure TfrmValidateEditDemo.btnSetDisplaySuffixClick(Sender: TObject);
begin
FValidateEdit.DisplaySuffix := edDisplaySuffix.Text;
end;
procedure TfrmValidateEditDemo.edCPMaxValueExit(Sender: TObject);
begin
FValidateEdit.CriticalPoints.MaxValue := StrToFloatDef(edCPMaxValue.Text, 0);
edCPMaxValue.Text := FloatToStr(FValidateEdit.CriticalPoints.MaxValue);
end;
procedure TfrmValidateEditDemo.edCPMinValueExit(Sender: TObject);
begin
FValidateEdit.CriticalPoints.MinValue := StrToFloatDef(edCPMinValue.Text, 0);
edCPMinValue.Text := FloatToStr(FValidateEdit.CriticalPoints.MinValue);
end;
procedure TfrmValidateEditDemo.colCPAboveChange(Sender: TObject);
begin
FValidateEdit.CriticalPoints.ColorAbove := colCpAbove.ColorValue;
end;
procedure TfrmValidateEditDemo.colCPBelowChange(Sender: TObject);
begin
FValidateEdit.CriticalPoints.ColorBelow := colCpBelow.ColorValue;
end;
procedure TfrmValidateEditDemo.cbCPCheckPointsChange(Sender: TObject);
begin
FValidateEdit.CriticalPoints.CheckPoints :=
TJvValidateEditCriticalPointsCheck(cbCPCheckPoints.ItemIndex);
end;
procedure TfrmValidateEditDemo.edMaxValueExit(Sender: TObject);
begin
FValidateEdit.MaxValue := StrToFloatDef(edMaxValue.Text, 0);
end;
procedure TfrmValidateEditDemo.edMinValueExit(Sender: TObject);
begin
FValidateEdit.MinValue := StrToFloatDef(edMinValue.Text, 0);
end;
end.
--- NEW FILE: Notes.txt ---
TJvValidateEdit
unit = JvValidateEdit
inherits from TJvCustomEdit
Introduced behaviour:
=====================
Properties:
===========
[Public]
AsCurrency: Currency
The value as an Currency
AsFloat: Integer
The value as an Double
AsInteger: Integer
The value as an integer
[Published]
CheckChars: string
The characters that are allowed to be entered (or in the case of dfNonCheckChars, *not* allowed)
True numeric types (dfCurrency, dfFloat, dfInteger, dfPercent, dfScientific and dfYear) are allowed to have a leading + or - as well.
Changing CheckChars triggers a re-Validation of the Text.
CriticalPoints: TCriticalPoints
Critical points only work for the numeric DisplayFormat styles. Unlike MaxValue and MinValue, you can exceed a CriticalPoint, but it will apply a colour to the value when it falls outside the range specified. CriticalPoints.MinValue and CriticalPoints.MaxValue define the range in which the Value has the original colour set for the Font. If the Value falls below CriticalPoints.MinValue, the Value gets the colour CriticalPoints.ColorBelow and if the Value goes above CriticalPoints.MaxValue, the Value gets the colour CriticalPoints.ColorAbove. CriticalPoints.CheckPoints defines how many points are checked, and may have the values cpNone, cpMax or cpBoth. cpNone is the default and means no colouring is done; cpMaxValue means that only the MaxValue is checked; cpBoth mean both the MaxValue and the MinValue are checked.
DecimalPlaces: Cardinal
For numeric types that support decimals (dfCurrency, dfFloat, dfPercent, and dfScientific), the number of decimals displayed. The actual edit value will be rounded to this number of decimal places if a greater precision is entered.
dfCurrency may only have up to 4 decimals.
DisplayFormat: enumerated type
dfAlphabetic, dfAlphaNumeric, dfBinary, dfCheckChars, dfCurrency, dfCustom, dfFloat, dfHex, dfInteger, dfNonCheckChars, dfNone, dfOctal, dfPercent, dfScientific, dfYear
Controls the key that can be entered, and how the display is formatted.
Modifies CheckChars to the appropriate characters to check.
Changing DisplayFormat triggers a re-Validation of the Text.
DisplayPrefix: string
A string that will be prepended to the displayed value. For example, to show Australian currency you would set the DisplayFormat to dfCurrency and the DisplayPrefix to 'AU' so a Value of 10 would display 'AU$10.00'
DisplaySuffix: string
A string that will be appended to the displayed value.
EditText: string
The text as entered (unformatted)
HasMaxValue: boolean
Specifies whether the property MaxValue is to be checked to ensure the value entered is within the range.
HasMinValue
Specifies whether the property MinValue is to be checked to ensure the value entered is within the range.
MaxValue: Double
The maximum value the entered value can have
MinValue: Double
The minimum value the entered value can have
Text: string
The formatted text
Value: Variant
The value of the entered value. The type will vary depending on DisplayFormat
ZeroEmpty: Boolean
Whether to display an empty edit box when the value is 0
Events:
=======
OnCustomValidate(Sender: TObject; Key: Char; const AText: string; var IsValid: boolean)
Called on each keystroke when the DisplayFormat is dfCustom so the user can validate the characters
OnValueChanged(Sender: TObject)
Triggers when the value is changed, either by an assignment of a value or on exit from the field if the value of the field as been edited
Problems:
=========
TJvValidateFormat uses the SysUtils.Format function to format numeric values. While this uses the Windows regional settings for the currency symbol, decimal separator and thousands separator, it does not format using the negative symbol, negative number format, negative currency format and positive currency format. This could be rectified by a custom written formatting routine.
--- NEW FILE: readme.txt ---
TJvValidateEdit
unit = JvValidateEdit
inherits from TJvCustomEdit
Introduced behaviour:
=====================
Properties:
===========
[Public]
AsCurrency: Currency
The value as an Currency
AsFloat: Integer
The value as an Double
AsInteger: Integer
The value as an integer
[Published]
AutoAlignment: boolean
When True, the Alignment is automatically assigned to taRightJustify for numbers and taLeftJustify for text when the DisplayFormat changes.
CheckChars: string
The characters that are allowed to be entered (or in the case of dfNonCheckChars, *not* allowed)
True numeric types (dfCurrency, dfFloat, dfInteger, dfPercent, dfScientific and dfYear) are allowed to have a leading + or - as well.
Changing CheckChars triggers a re-Validation of the Text.
CriticalPoints: TCriticalPoints
Critical points only work for the numeric DisplayFormat styles. Unlike MaxValue and MinValue, you can exceed a CriticalPoint, but it will apply a colour to the value when it falls outside the range specified. CriticalPoints.MinValue and CriticalPoints.MaxValue define the range in which the Value has the original colour set for the Font. If the Value falls below CriticalPoints.MinValue, the Value gets the colour CriticalPoints.ColorBelow and if the Value goes above CriticalPoints.MaxValue, the Value gets the colour CriticalPoints.ColorAbove. CriticalPoints.CheckPoints defines how many points are checked, and may have the values cpNone, cpMax or cpBoth. cpNone is the default and means no colouring is done; cpMaxValue means that only the MaxValue is checked; cpBoth mean both the MaxValue and the MinValue are checked.
DecimalPlaces: Cardinal
For numeric types that support decimals (dfCurrency, dfFloat, dfPercent, and dfScientific), the number of decimals displayed. The actual edit value will be rounded to this number of decimal places if a greater precision is entered.
dfCurrency may only have up to 4 decimals.
DisplayFormat: enumerated type
dfAlphabetic, dfAlphaNumeric, dfBinary, dfCheckChars, dfCurrency, dfCustom, dfFloat, dfHex, dfInteger, dfNonCheckChars, dfNone, dfOctal, dfPercent, dfScientific, dfYear
Controls the key that can be entered, and how the display is formatted.
Modifies CheckChars to the appropriate characters to check.
Changing DisplayFormat triggers a re-Validation of the Text.
DisplayPrefix: string
A string that will be prepended to the displayed value. For example, to show Australian currency you would set the DisplayFormat to dfCurrency and the DisplayPrefix to 'AU' so a Value of 10 would display 'AU$10.00'
DisplaySuffix: string
A string that will be appended to the displayed value.
EditText: string
The text as entered (unformatted)
HasMaxValue: boolean
Specifies whether the property MaxValue is to be checked to ensure the value entered is within the range.
HasMinValue
Specifies whether the property MinValue is to be checked to ensure the value entered is within the range.
MaxValue: Double
The maximum value the entered value can have
MinValue: Double
The minimum value the entered value can have
Text: string
The formatted text
Value: Variant
The value of the entered value. The type will vary depending on DisplayFormat
ZeroEmpty: Boolean
Whether to display an empty edit box when the value is 0
Events:
=======
OnCustomValidate(Sender: TObject; Key: Char; const AText: string; var IsValid: boolean)
Called on each keystroke when the DisplayFormat is dfCustom so the user can validate the characters
OnValueChanged(Sender: TObject)
Triggers when the value is changed, either by an assignment of a value or on exit from the field if the value of the field as been edited
Problems:
=========
TJvValidateFormat uses the SysUtils.Format function to format numeric values. While this uses the Windows regional settings for the currency symbol, decimal separator and thousands separator, it does not format using the negative symbol, negative number format, negative currency format and positive currency format. This could be rectified by a custom written formatting routine.
|