Class TCurrencyEdit (unit RCurrEdt) |
Inherits from
TCustomMemo
* Renamed from CurrEdit.pas 6/14/1998 Paul Rice to avoid conflict with others' work.
This is my first custom control, so please be merciful. I needed a simple
currency edit field, so below is my attempt. It has pretty good behavior
and I have posted it up to encourage others to share their code as well.
Essentially, the CurrencyEdit field is a modified memo field. I have put
in keyboard restrictions, so the user cannot enter invalid characters.
When the user leaves the field, the number is reformatted to display
appropriately. You can left-, center-, or right-justify the field, and
you can also specify its display format - see the FormatFloat command.
The field value is stored in a property called Value so you should read
and write to that in your program. This field is of type Extended.
If you like this control you can feel free to use it, however, if you
modify it, I would like you to send me whatever you did to it. If you
send me your CIS ID, I will send you copies of my custom controls that
I develop in the future. Please feel free to send me anything you are
working on as well. Perhaps we can spark ideas!
Robert Vivrette, Owner
Prime Time Programming
PO Box 5018
Walnut Creek, CA 94596-1018
Fax: (510) 939-3775
CIS: 76416,1373
Net: RobertV@ix.netcom.com
Thanks to Massimo Ottavini, Thorsten Suhr, Bob Osborn, Mark Erbaugh, Ralf
Gosch, Julian Zagorodnev, and Grant R. Boggs for their enhancements!
constructor Create(AOwner: TComponent);
procedure CreateParams(var Params: TCreateParams);
... and only at beginning
procedure KeyPress(var Key: Char);
procedure CMEnter(var Message: TCMEnter);
procedure CMExit(var Message: TCMExit);
procedure FormatText;
procedure SetDecimalPlaces(A: Word);
procedure SetFieldValue(A: Extended);
procedure SetFormat(A: string);
WantReturns := False;
procedure SetNegColor(A: TColor);
procedure SetPosColor(A: TColor);
procedure UnFormatText;
property Alignment :
property AutoSize :
property BorderStyle :
property Color :
property Ctl3D :
property DecimalPlaces : Word
property DisplayFormat : string
property DragCursor :
property DragMode :
property Enabled :
property Font :
property HideSelection :
property MaxLength :
property NegColor : TColor
property ParentColor :
property ParentCtl3D :
property ParentFont :
property ParentShowHint :
property PopupMenu :
property PosColor : TColor
property ReadOnly :
property ShowHint :
property TabOrder :
property Value : Extended
property Visible :
event OnChange :
event OnClick :
event OnDblClick :
event OnDragDrop :
event OnDragOver :
event OnEndDrag :
event OnEnter :
event OnExit :
event OnKeyDown :
event OnKeyPress :
event OnKeyUp :
event OnMouseDown :
event OnMouseMove :
event OnMouseUp :
DispFormat : string;
FDecimalPlaces : Word;
FieldValue : Extended;
FNegColor : TColor;
FPosColor : TColor;
constructor Create(AOwner: TComponent);
procedure CreateParams(var Params: TCreateParams);
... and only at beginning
procedure KeyPress(var Key: Char);
procedure CMEnter(var Message: TCMEnter);
procedure CMExit(var Message: TCMExit);
procedure FormatText;
procedure SetDecimalPlaces(A: Word);
procedure SetFieldValue(A: Extended);
procedure SetFormat(A: string);
WantReturns := False;
procedure SetNegColor(A: TColor);
procedure SetPosColor(A: TColor);
procedure UnFormatText;
property Alignment :
property AutoSize :
property BorderStyle :
property Color :
property Ctl3D :
property DecimalPlaces : Word
property DisplayFormat : string
property DragCursor :
property DragMode :
property Enabled :
property Font :
property HideSelection :
property MaxLength :
property NegColor : TColor
property ParentColor :
property ParentCtl3D :
property ParentFont :
property ParentShowHint :
property PopupMenu :
property PosColor : TColor
property ReadOnly :
property ShowHint :
property TabOrder :
property Value : Extended
property Visible :
event OnChange :
event OnClick :
event OnDblClick :
event OnDragDrop :
event OnDragOver :
event OnEndDrag :
event OnEnter :
event OnExit :
event OnKeyDown :
event OnKeyPress :
event OnKeyUp :
event OnMouseDown :
event OnMouseMove :
event OnMouseUp :
DispFormat : string;
FDecimalPlaces : Word;
FieldValue : Extended;
FNegColor : TColor;
FPosColor : TColor;