From 51a647988c7d994624de1991b71b7c7eb8acdb7f Mon Sep 17 00:00:00 2001 From: skalogryz Date: Tue, 12 Apr 2016 00:44:04 +0000 Subject: [PATCH] richmemo: win32, remove the limitation to default (32K or 64K) characters, when MaxLength of RichMemo is set to 0. The issue reported by TraumTaenzerDieter on the forum. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4617 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/win32/win32richmemo.pas | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/richmemo/win32/win32richmemo.pas b/components/richmemo/win32/win32richmemo.pas index ea6b8c8b1..d8d50a941 100644 --- a/components/richmemo/win32/win32richmemo.pas +++ b/components/richmemo/win32/win32richmemo.pas @@ -80,7 +80,9 @@ type class procedure SetTextAttributes(const AWinControl: TWinControl; TextStart, TextLen: Integer; const Params: TIntFontParams); override; - class procedure SetHideSelection(const ACustomEdit: TCustomEdit; AHideSelection: Boolean); override; + class procedure SetHideSelection(const ACustomEdit: TCustomEdit; AHideSelection: Boolean); override; + class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; + class function GetStyleRange(const AWinControl: TWinControl; TextStart: Integer; var RangeStart, RangeLen: Integer): Boolean; override; class procedure SetTextUIParams(const AWinControl: TWinControl; TextStart, TextLen: Integer; @@ -524,8 +526,12 @@ begin eventmask := eventmask or ENM_SELCHANGE or ENM_LINK; SendMessage(AWinControl.Handle, EM_SETEVENTMASK, 0, eventmask); + // Limitless text. However, the value would be overwritten by a consequent + // SetMaxLength call, see above. + SendMessage(AWincontrol.Handle, EM_EXLIMITTEXT, 0, LParam(-1)); + // memo is not a transparent control -> no need for parentpainting - PArams.WindowInfo^.ParentMsgHandler := @RichEditNotifyProc; + Params.WindowInfo^.ParentMsgHandler := @RichEditNotifyProc; Params.WindowInfo^.needParentPaint := false; Result := Params.Window; end; @@ -628,6 +634,22 @@ begin RichEditManager.SetHideSelection(ACustomEdit.Handle, AHideSelection); end; +class procedure TWin32WSCustomRichMemo.SetMaxLength( + const ACustomEdit: TCustomEdit; NewLength: integer); +var + winhandle: HWND; + relen : Integer; +begin + winhandle := ACustomEdit.Handle; + // By default NewLength=0. For RichEdit that means 64K or 32K limitation. + // Which makes no sense and isn't cross platform! + // RichMemo assumes NewLength=0 as limitless + if NewLength=0 then relen:=-1 // limitless + else relen:=NewLength; + SendMessage(winhandle, EM_EXLIMITTEXT, 0, LParam(relen)); + GetWin32WindowInfo(winhandle)^.MaxLength := NewLength; +end; + procedure InitScrollInfo(var info: TScrollInfo); begin FillChar(info, sizeof(info), 0);