diff --git a/lcl/include/customedit.inc b/lcl/include/customedit.inc index 7d397c5adc..73b21c8468 100644 --- a/lcl/include/customedit.inc +++ b/lcl/include/customedit.inc @@ -51,6 +51,7 @@ begin //FCompStyle is set here because TEdit inherits from this. //TCustomMemo also inherits from here but it's create changes fcompstyle to csMemo FCompStyle := csEdit; + FMaxLength:= -1; Height:=23; end; @@ -219,11 +220,26 @@ end; Params: Value to set FReadOnly to Returns: Nothing ------------------------------------------------------------------------------} -Procedure TCustomEdit.SetReadOnly(Value : Boolean); -Begin -FReadOnly := Value; -CNSendMessage(LM_SETPROPERTIES, Self, nil); -End; +procedure TCustomEdit.SetReadOnly(Value : Boolean); +begin + if FreadOnly <> Value then begin + FReadOnly := Value; + CNSendMessage(LM_SETPROPERTIES, Self, nil); + end; +end; + +{------------------------------------------------------------------------------ + Method: TCustomEdit.SetText + Params: Override of text setup to watch for max length + Returns: Nothing + ------------------------------------------------------------------------------} +procedure TCustomEdit.SetText(const Value: TCaption); +begin + if (MaxLength >= 0) and (Length(Value) > MaxLength) then + inherited SetText(Copy(Value, 1, MaxLength)) + else + inherited SetText(Value); +end; {------------------------------------------------------------------------------ Method: TCustomEdit.SetModified @@ -274,6 +290,9 @@ end; { ============================================================================= $Log$ + Revision 1.13 2002/11/16 11:22:57 mbukovjan + Fixes to MaxLength. TCustomMemo now has MaxLength, too. + Revision 1.12 2002/11/13 08:40:44 lazarus MB: Fixed selection start/end/text for edits and combos. Add support for memos. diff --git a/lcl/stdctrls.pp b/lcl/stdctrls.pp index 182ec21ca8..28ff747e4a 100644 --- a/lcl/stdctrls.pp +++ b/lcl/stdctrls.pp @@ -299,7 +299,7 @@ type property ItemHeight; property ItemWidth; property Items; - property MaxLength; + property MaxLength default -1; property ParentCtl3D; property ParentFont; property ParentShowHint; @@ -446,6 +446,7 @@ type procedure SetSelLength(Val : integer); virtual; procedure SetSelStart(Val : integer); virtual; procedure SetSelText(const Val : string); virtual; + procedure SetText(const Value: TCaption); override; property OnChange : TNotifyEvent read FOnChange write FOnChange; public @@ -453,7 +454,7 @@ type procedure SelectAll; property CharCase : TEditCharCase read FCharCase write SetCharCase default ecNormal; property EchoMode : TEchoMode read FEchoMode write SetEchoMode default emNormal; - property MaxLength : Integer read FMaxLength write SetMaxLength default 0; + property MaxLength : Integer read FMaxLength write SetMaxLength default -1; property ReadOnly : Boolean read FReadOnly write SetReadOnly default false; property SelLength: integer read GetSelLength write SetSelLength; property SelStart: integer read GetSelStart write SetSelStart; @@ -525,6 +526,7 @@ type property Color; property Font; property Lines; + property MaxLength; property PopupMenu; property ReadOnly; property ScrollBars; @@ -535,8 +537,8 @@ type property OnEnter; property OnExit; property OnKeyPress; - Property OnKeyDown; - Property OnKeyUp; + property OnKeyDown; + property OnKeyUp; end; @@ -1380,6 +1382,9 @@ end. { ============================================================================= $Log$ + Revision 1.67 2002/11/16 11:22:56 mbukovjan + Fixes to MaxLength. TCustomMemo now has MaxLength, too. + Revision 1.66 2002/11/12 10:16:14 lazarus MG: fixed TMainMenu creation