0

I am building an app (D5) that uses a TSpeedButton and the Glyphs are loaded at runtime.

All good, but the positioning options, Top, Left, Right and Bottom are pretty clunky as a 32 x 32 Glyph on a 40 x 40 button always goes to the top left, right or bottom.

How can I center the Glyph vertically and Horizontally so that the

Glyph.Top = 4;
Glyph.Left = 4;

and the 32 x 32 picture is centered in the button.

Thank you.

user2566616
  • 103
  • 1
  • 5
  • 1
    Create a 40px bitmap and paint your image into it at 4,4. Use that as your glyph. – David Heffernan Aug 24 '13 at 18:04
  • @DavidHeffernan Thanks for the reply, but I should have mentioned that the Glyphs are icons from installed programs on the PC. I have no control over them other than selecting the 32x32 version if there are multiple sizes in the program. – user2566616 Aug 24 '13 at 19:44
  • 2
    You are a programmer. Of course you can control this. It's trivially easy to do what I describe. – David Heffernan Aug 24 '13 at 20:41
  • @DavidHeffernan Huh? Have I offended you in some way? If it was trivial to **ME**, I would not be wasting **both** our time, asking here. Is there a mandatory level of expertise required to ask questions here? Silly me, I thought this was a Help system. :) – user2566616 Aug 24 '13 at 22:40
  • @user2566616: instead of loading an icon directly into the button, have your code create a `TBitmap`, size it to 40x40, `Draw()` the icon onto it at a 4x4 offset, and then load that bitmap onto the button. – Remy Lebeau Aug 25 '13 at 00:51
  • 1
    You've not offended me at all. You just said that what I suggested was not possible. I merely disagreed with that. What I suggested is possible and in fact is extremely easy to do. And it will be easy for you. – David Heffernan Aug 25 '13 at 07:42

1 Answers1

2

Set the Layout to blGlyphLeft and Margin to -1. That should center the glyph inside the button.

Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130