@@ -1607,6 +1607,8 @@ procedure CalcImageAndTextRect(const ASurfaceRect: TRect;
16071607 IW, IH, IX, IY: Integer;
16081608 LImageAlignment: TImageAlignment;
16091609begin
1610+ // Calculate Image and Text Rect for Drawing using ImageAlignment and ImageMargins
1611+ // for StyledButton and StyledGraphicButton
16101612 if ACaption = ' ' then
16111613 LImageAlignment := iaCenter
16121614 else
@@ -1722,6 +1724,8 @@ procedure CalcImageAndTextRect(const ACanvas: TCanvas;
17221724 LLayout: TButtonLayout;
17231725 LMargin, LSpacing: Integer;
17241726begin
1727+ // Calculate Image and Text Rect for Drawing using ButtonLayout, Margin and Spacing
1728+ // For StyledSpeedButton and StyledBitBtn
17251729 LLayout := ALayout;
17261730 if (ABiDiFlags and DT_RIGHT) = DT_RIGHT then
17271731 begin
@@ -1835,7 +1839,8 @@ procedure CalcImageAndTextRect(const ACanvas: TCanvas;
18351839 Inc(AGlyphPos.X, ASurfaceRect.Left + AOffset.X);
18361840 Inc(AGlyphPos.Y, ASurfaceRect.Top + AOffset.Y);
18371841
1838- OffsetRect(ATextBounds, LTextPos.X + ASurfaceRect.Left + AOffset.X, LTextPos.Y + ASurfaceRect.Top + AOffset.Y);
1842+ OffsetRect(ATextBounds, LTextPos.X + ASurfaceRect.Left + AOffset.X,
1843+ LTextPos.Y + ASurfaceRect.Top + AOffset.Y);
18391844end ;
18401845
18411846procedure DrawIconFromCommandLinkRes (ACanvas: TCanvas; ARect: TRect;
@@ -2044,7 +2049,7 @@ procedure DrawButtonText(const ACanvas: TCanvas;
20442049 const PreserveBorders: Boolean = True);
20452050var
20462051 R: TRect;
2047- OldBKMode : Integer;
2052+ LOldBKMode : Integer;
20482053begin
20492054(* for test
20502055 ACanvas.Brush.Color := clYellow;
@@ -2065,7 +2070,7 @@ procedure DrawButtonText(const ACanvas: TCanvas;
20652070 else
20662071 OffsetRect(R, (ARect.Width - R.Width) div 2 , (ARect.Height - R.Height) div 2 );
20672072 end ;
2068- OldBKMode := SetBkMode(ACanvas.Handle, Winapi.Windows.TRANSPARENT);
2073+ LOldBKMode := SetBkMode(ACanvas.Handle, Winapi.Windows.TRANSPARENT);
20692074 try
20702075 if PreserveBorders then
20712076 begin
@@ -2075,13 +2080,13 @@ procedure DrawButtonText(const ACanvas: TCanvas;
20752080 R.Top := ARect.Top + ABorderWidth + ASpacing ;
20762081 if R.Bottom > ARect.Bottom - ABorderWidth - Aspacing then
20772082 R.Bottom := ARect.Bottom - ABorderWidth - Aspacing;
2078- (* for test
2079- ACanvas.Brush.Color := clRed;
2080- ACanvas.FillRect(R);
2081- ACanvas.Pen.Color := clBlue;
2082- ACanvas.Pen.Width := 1;
2083- ACanvas.Rectangle(R);
2084- *)
2083+ (* for test
2084+ ACanvas.Brush.Color := clRed;
2085+ ACanvas.FillRect(R);
2086+ ACanvas.Pen.Color := clBlue;
2087+ ACanvas.Pen.Width := 1;
2088+ ACanvas.Rectangle(R);
2089+ *)
20852090 Winapi.Windows.DrawText(ACanvas.Handle, PChar(AText),
20862091 Length(AText), R, ABidiFlags or DT_END_ELLIPSIS);
20872092 end
@@ -2097,7 +2102,7 @@ procedure DrawButtonText(const ACanvas: TCanvas;
20972102 Length(AText), R, ABidiFlags);
20982103 end ;
20992104 finally
2100- SetBkMode(ACanvas.Handle, OldBKMode );
2105+ SetBkMode(ACanvas.Handle, LOldBKMode );
21012106 end ;
21022107end ;
21032108
0 commit comments