home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
MASK.INT
< prev
next >
Wrap
Text File
|
1997-02-28
|
4KB
|
143 lines
{*******************************************************}
{ }
{ Delphi Visual Component Library }
{ }
{ Copyright (c) 1995,96 Borland International }
{ }
{*******************************************************}
unit Mask;
{$R-}
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;
procedure ValidateError;
procedure CheckCursor;
property EditMask: string;
property MaskState: TMaskedState;
property MaxLength: Integer;
public
constructor Create(AOwner: TComponent); override;
procedure ValidateEdit;
procedure Clear;
function GetTextLen: Integer;
property IsMasked: Boolean;
property EditText: string;
property Text: string;
end;
{ TMaskEdit }
TMaskEdit = class(TCustomMaskEdit)
published
property AutoSelect;
property AutoSize;
property BorderStyle;
property CharCase;
property Color;
property Ctl3D;
property DragCursor;
property DragMode;
property Enabled;
property EditMask;
property Font;
property ImeMode;
property ImeName;
property MaxLength;
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 OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
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