From b89b37d10720d4b632faf5b15992d263b0f2c5aa Mon Sep 17 00:00:00 2001 From: ondrej Date: Sat, 19 Mar 2016 12:53:18 +0000 Subject: [PATCH] win32: edit: disable margins git-svn-id: trunk@51985 - --- lcl/interfaces/win32/win32wsstdctrls.pp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lcl/interfaces/win32/win32wsstdctrls.pp b/lcl/interfaces/win32/win32wsstdctrls.pp index 94c4a5ab17..ccf15cd95c 100644 --- a/lcl/interfaces/win32/win32wsstdctrls.pp +++ b/lcl/interfaces/win32/win32wsstdctrls.pp @@ -149,6 +149,8 @@ type { TWin32WSCustomEdit } TWin32WSCustomEdit = class(TWSCustomEdit) + private + class procedure ApplyMargins(const AWinControl: TWinControl); published class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override; @@ -174,6 +176,7 @@ type class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; class procedure SetText(const AWinControl: TWinControl; const AText: string); override; + class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override; class procedure Cut(const ACustomEdit: TCustomEdit); override; class procedure Copy(const ACustomEdit: TCustomEdit); override; @@ -1150,6 +1153,8 @@ begin // edit is not a transparent control -> no need for parentpainting Params.WindowInfo^.needParentPaint := false; Result := Params.Window; + + ApplyMargins(AWinControl); end; class function TWin32WSCustomEdit.GetCanUndo(const ACustomEdit: TCustomEdit): Boolean; @@ -1234,6 +1239,14 @@ begin // nothing to do, SetPasswordChar will do the work end; +class procedure TWin32WSCustomEdit.SetFont(const AWinControl: TWinControl; + const AFont: TFont); +begin + inherited SetFont(AWinControl, AFont); + + ApplyMargins(AWinControl); +end; + class procedure TWin32WSCustomEdit.SetHideSelection(const ACustomEdit: TCustomEdit; NewHideSelection: Boolean); var CurrentStyle: DWord; @@ -1299,6 +1312,12 @@ begin SendMessage(ACustomEdit.Handle, WM_CUT, 0, 0) end; +class procedure TWin32WSCustomEdit.ApplyMargins(const AWinControl: TWinControl); +begin + if (WindowsVersion >= wv2000) and AWinControl.HandleAllocated then + SendMessage(AWinControl.Handle, EM_SETMARGINS, EC_LEFTMARGIN or EC_RIGHTMARGIN, 0); +end; + class procedure TWin32WSCustomEdit.Copy(const ACustomEdit: TCustomEdit); begin SendMessage(ACustomEdit.Handle, WM_COPY, 0, 0)