From 3c1f7de3ea25467e45b98a0cd72b166e198cf3c5 Mon Sep 17 00:00:00 2001 From: juha Date: Fri, 22 Apr 2016 08:54:36 +0000 Subject: [PATCH] LCL: Fix TSpeedButton AutoSize with alignment. Issue #27396, patch from Michl. git-svn-id: trunk@52231 - --- lcl/include/speedbutton.inc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lcl/include/speedbutton.inc b/lcl/include/speedbutton.inc index 93b8972a03..72ea2a8dbd 100644 --- a/lcl/include/speedbutton.inc +++ b/lcl/include/speedbutton.inc @@ -1009,26 +1009,25 @@ end; function TCustomSpeedButton.GetTextSize(Drawing: boolean; PaintRect: TRect): TSize; var TMP: String; - TXTStyle: TTextStyle; Flags: Cardinal; + DC: HDC; // ~bk see : TCustomLabel.CalculateSize + OldFont: HGDIOBJ; // " begin if FShowCaption and (Caption <> '') then begin TMP := Caption; - TXTStyle := Canvas.TextStyle; - TXTStyle.Opaque := False; - TXTStyle.Clipping := True; - TXTStyle.ShowPrefix := ShowAccelChar; - TXTStyle.Alignment := taLeftJustify; - TXTStyle.Layout := tlTop; - TXTStyle.RightToLeft := UseRightToLeftReading; - TXTStyle.SystemFont := Canvas.Font.IsDefault;//Match System Default Style DeleteAmpersands(TMP); - Flags := DT_CalcRect; - if not TXTStyle.SingleLine then Inc(Flags, DT_WordBreak); - - DrawText(Canvas.Handle, PChar(TMP), Length(TMP), PaintRect, Flags); + if not Canvas.TextStyle.SingleLine then + Inc(Flags, DT_WordBreak); + DC := GetDC(Parent.Handle); + try + OldFont := SelectObject(DC, HGDIOBJ(Font.Reference.Handle)); + DrawText(DC, PChar(TMP), Length(TMP), PaintRect, Flags); + SelectObject(DC, OldFont); + finally + ReleaseDC(Parent.Handle, DC); + end; Result.CY := PaintRect.Bottom - PaintRect.Top; Result.CX := PaintRect.Right - PaintRect.Left; end