Problem with button Bagra lazarus / 39-Graphics ---------------------------------------------------------------------- essam eddine adib · 2019-07-03 07:11 Hi, I want to have a button with centered glyph and label in bottom or top but when i choose cabottomcenter for label it center it compared to free space let by glyph. i join screen to what i have and what i want to have (By changing code in source code i obtain what i want but it not recommended thank's for help ---------------------------------------------------------------------- coasting · 2019-07-03 09:04 The standard routines misalign the position of Caption and Image. Have a look into the Ribbon Demo provided with the BGRA package. ---------------------------------------------------------------------- essam eddine adib · 2019-07-04 16:30 thank you for response I saw what they do in in BGRA ribbon example but i could not reproduce it in new project can U help me thank's a lot ---------------------------------------------------------------------- coasting · 2019-07-05 09:14 See an example here below and attached... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, BCButton, Forms, Controls, Graphics, Dialogs,  Types, BGRABitmap, BGRABitmapTypes; type   { TForm1 }   TForm1 = class(TForm)    BCButton1: TBCButton;    BCButton2: TBCButton;    ImageList32: TImageList;    procedure BCButton1AfterRenderBCButton(Sender: TObject;      const ABGRA: TBGRABitmap; AState: TBCButtonState; ARect: TRect);    procedure FormCreate(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.BCButton1AfterRenderBCButton(Sender: TObject;  const ABGRA: TBGRABitmap; AState: TBCButtonState; ARect: TRect);var  myText: string;  myRect: TRect;  tw: integer;  c: TBGRAPixel;begin{ Custom painting of Caption and Image needed, as standard routines misalign the  position of Caption and Image }   ABGRA.FontName := 'Segoe UI';  ABGRA.FontHeight := 14;   myText := TBCButton(Sender).Caption;   { Defining myRect with Bottom -12px }  myRect.Bottom := ARect.Bottom - 12;  myRect.Left := ARect.Left;  myRect.Right := ARect.Right;  myRect.Top := ARect.Left;   { Determining the width/height of Caption. We need only width }  tw := ABGRA.TextSize(mytext).cx;  c := clRed;   if tw > TBCButton(Sender).Width then  begin    { Caption doesnt fit in one line, reduce Fontsize }    ABGRA.FontHeight := 13;    ABGRA.TextRect(ARect, myText, taCenter, tlBottom, c);  end  else  begin    { Caption fits in one line }    ABGRA.TextRect(myRect, myText, taCenter, tlBottom, c);  end;   { Painting of Image on Button }  ImageList32.Draw(ABGRA.Canvas, (TBCButton(Sender).Width - 32) div 2, 4,    TBCButton(Sender).ImageIndex);end; procedure TForm1.FormCreate(Sender: TObject);begin  BCButton1.ShowCaption := False;  BCButton1.Images := nil;  BCButton2.ShowCaption := False;  BCButton2.Images := nil;end; end.