ExCtrls/TButtonEx: Fix wordwrapped custom-drawn caption not being centered.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7985 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-03-28 18:00:00 +00:00
parent 8f8e736b98
commit c0acf0abb4
3 changed files with 12 additions and 1 deletions

View File

@@ -418,6 +418,7 @@ var
i: integer;
txtSize: TSize;
txtPt: TPoint;
ts: TTextStyle;
begin
if (csDestroying in ComponentState) or not HandleAllocated then
exit;
@@ -526,7 +527,13 @@ begin
end;
txtPt.Y := (Height - txtSize.CY + 1) div 2;
R := Rect(txtPt.X, txtPt.Y, txtPt.X + txtSize.CX, txtPt.Y + txtSize.CY);
DrawText(lCanvas.Handle, PChar(Caption), -1, R, flags);
ts := lCanvas.TextStyle;
ts.Alignment := lAlignment;
ts.Layout := tlCenter;
ts.SingleLine := not FWordWrap;
ts.Wordbreak := FWordWrap;
lCanvas.TextRect(R, txtPt.X, txtPt.Y, Caption, ts);
// Draw focus rectangle
if FShowFocusRect and Focused then