home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Plus! (NZ) 2001 June
/
HDC50.iso
/
Runimage
/
Delphi50
/
Doc
/
MASK.INT
< prev
next >
Wrap
Text File
|
1999-08-11
|
5KB
|
152 lines
{*******************************************************}
{ }
{ Borland Delphi Visual Component Library }
{ }
{ Copyright (c) 1995,99 Inprise Corporation }
{ }
{*******************************************************}
unit Mask;
{$R-,T-,H+,X+}
interface
uses Windows, SysUtils, Classes, StdCtrls, Controls, Messages,
Forms, Graphics, Menus;
const
DefaultBlank: Char = '_';
MaskFieldSeparator: Char = ';';
MaskNoSave: Char = '0';
mDirReverse = '!'; { removes leading blanks if true, else trailing blanks}
mDirUpperCase = '>'; { all chars that follow to upper case }
mDirLowerCase = '<'; { all chars that follow to lower case }
{ '<>' means remove casing directive }
mDirLiteral = '\'; { char that immediately follows is a literal }
mMskAlpha = 'L'; { in US = A-Z,a-z }
mMskAlphaOpt = 'l';
mMskAlphaNum = 'A'; { in US = A-Z,a-z,0-9 }
mMskAlphaNumOpt = 'a';
mMskAscii = 'C'; { any character}
mMskAsciiOpt = 'c';
mMskNumeric = '0'; { 0-9, no plus or minus }
mMskNumericOpt = '9';
mMskNumSymOpt = '#'; { 0-9, plus and minus }
{ intl literals }
mMskTimeSeparator = ':';
mMskDateSeparator = '/';
type
TMaskCharType = (mcNone, mcLiteral, mcIntlLiteral, mcDirective, mcMask,
mcMaskOpt, mcFieldSeparator, mcField);
TMaskDirectives = set of (mdReverseDir, mdUpperCase, mdLowerCase,
mdLiteralChar);
type
{ Exception class }
EDBEditError = class(Exception);
TMaskedState = set of (msMasked, msReEnter, msDBSetText);
{ TCustomMaskEdit }
TCustomMaskEdit = class(TCustomEdit)
protected
procedure ReformatText(const NewMask: string);
procedure GetSel(var SelStart: Integer; var SelStop: Integer);
procedure SetSel(SelStart: Integer; SelStop: Integer);
procedure SetCursor(Pos: Integer);
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
function EditCanModify: Boolean; virtual;
procedure Reset; virtual;
function GetFirstEditChar: Integer;
function GetLastEditChar: Integer;
function GetNextEditChar(Offset: Integer): Integer;
function GetPriorEditChar(Offset: Integer): Integer;
function GetMaxChars: Integer;
function Validate(const Value: string; var Pos: Integer): Boolean; virtual;
procedure ValidateError; virtual;
procedure CheckCursor;
property EditMask: string;
property MaskState: TMaskedState;
property MaxLength: Integer default 0;
public
constructor Create(AOwner: TComponent); override;
procedure ValidateEdit; virtual;
procedure Clear; override;
function GetTextLen: Integer;
property IsMasked: Boolean;
property EditText: string;
property Text: string;
end;
{ TMaskEdit }
TMaskEdit = class(TCustomMaskEdit)
published
property Anchors;
property AutoSelect;
property AutoSize;
property BiDiMode;
property BorderStyle;
property CharCase;
property Color;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property EditMask;
property Font;
property ImeMode;
property ImeName;
property MaxLength;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;
function FormatMaskText(const EditMask: string; const Value: string): string;
function MaskGetMaskSave(const EditMask: string): Boolean;
function MaskGetMaskBlank(const EditMask: string): Char;
function MaskGetFldSeparator(const EditMask: string): Integer;
implementation