diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index bb65852664..bb67757d13 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -3874,6 +3874,8 @@ type X, Y: Integer); override; procedure UpdateState; class function GetControlClassDefaultSize: TSize; override; + procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; + const AXProportion, AYProportion: Double); override; public property SectionFromOriginalIndex[OriginalIndex: Integer]: THeaderSection read GetSectionFromOriginalIndex; diff --git a/lcl/include/headercontrol.inc b/lcl/include/headercontrol.inc index 3f4b7bb425..344efc8c18 100644 --- a/lcl/include/headercontrol.inc +++ b/lcl/include/headercontrol.inc @@ -412,11 +412,34 @@ begin Images, Section.ImageIndex); inc(ContentRect.Left, Images.Width + 2); end; - + if Section.Text <> '' then ThemeServices.DrawText(Canvas, Details, Section.Text, ContentRect, AlignmentMap[Section.Alignment] or DT_VCENTER or DT_SINGLELINE, 0); end; +procedure TCustomHeaderControl.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; + const AXProportion, AYProportion: Double); +var + I: integer; + Sect: THeaderSection; +begin + inherited; + + if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then + begin + Sections.BeginUpdate; + try + for I := 0 to Sections.Count-1 do + begin + Sect := Sections.Items[I]; + Sect.Width := Round(Sect.Width*AXProportion); + end; + finally + Sections.EndUpdate; + end; + end; +end; + procedure TCustomHeaderControl.ChangeScale(M, D: Integer); var I: integer;