View Issue Details

IDProjectCategoryView StatusLast Update
0038865LazarusLCLpublic2021-05-19 13:04
ReporterZaher Dirkey Assigned To 
Status newResolutionopen 
PlatformWindowsOSWindows 8.1 64 bit 
Summary0038865: TSpeedButton autosize with margin
DescriptionPut SpeedButton1 on the form, use
SpeedButton1.Caption := 'Speed Button';
SpeedButton1.AutoSize := True;
SpeedButton1.Margin := 5;

TSpeedButton calculate the size correctly in MeasureDraw but when painting it, it shifted by PaintBackground(PaintRect) (line about 855 in, because PaintBackground change Left (and Right) or PaintRect, when painting by theme, come from windows theme uxTheme.dll

to resolve it
procedure PaintBackground(var PaintRect: TRect); virtual;
procedure PaintBackground(PaintRect: TRect); virtual;

but idk how that will effects on other thing, it is need the maintainer to fix it.
TagsNo tags attached.
Fixed in Revision
Attached Files


Zaher Dirkey

2021-05-08 00:59


SpeedButtonAutoSize.png (858 bytes)   
SpeedButtonAutoSize.png (858 bytes)   


2021-05-15 20:05

developer   ~0130907

I can't check Delphi, but if I read some comments, Delphi behaves the same and it is not a bug, but a feature.

See e.g.:

> The Margin property does change the left margin of a TSpeedButton's caption, but only when the Layout property is set to
> blGlyphLeft, which it is set to by default. Change Layout to either blGlyphTop or blGlyphBottom, and you will be able to adjust,
> correspondingly, the top or the bottom margin of the caption.

Zaher Dirkey

2021-05-15 20:50

reporter   ~0130910

It is with AutoSize of TSpeedButton, I checked Delphi there is no AutoSize in Delphi TSpeedButton
it calculate the size wrong or let me say it calc it correct in measuring, but paint wrong in painting

Bart Broersma

2021-05-19 13:02

developer   ~0130957

At least it is counter intuitive: autosize is supposed to size the button so that it is at all time large enough for the glyph+caption.
IMO this should also work if Margin is set.

Bart Broersma

2021-05-19 13:04

developer   ~0130958

B.t.w. TBitBtn seems to have the same issue.

Issue History

Date Modified Username Field Change
2021-05-08 00:59 Zaher Dirkey New Issue
2021-05-08 00:59 Zaher Dirkey File Added: SpeedButtonAutoSize.png
2021-05-15 20:05 Michl Note Added: 0130907
2021-05-15 20:50 Zaher Dirkey Note Added: 0130910
2021-05-19 13:02 Bart Broersma Note Added: 0130957
2021-05-19 13:04 Bart Broersma Note Added: 0130958