[SOLVED] Setter not working lazarus / 31-LCL ---------------------------------------------------------------------- pcurtis · 2021-11-23 03:35 Why can't I set the image on this simple control? 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 mytestbtn; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, LResources, Forms, Controls, Graphics, ExtCtrls, Dialogs, Buttons,  lclintf; type   TMytestbtn = class(TCustomControl)  private    fbtnEXTRA : TBitBtn;    fImage : TBitmap;     procedure SetImage(aValue : TBitmap);  protected    public    constructor Create(AOwner : TComponent); override;    destructor Destroy; override;  published    property TheImage : TBitmap read fImage write SetImage;  end; procedure Register; implementation constructor TMytestbtn.Create(AOwner : TComponent);begin  inherited Create(AOwner);   fImage := TBitmap.Create;   Color := clLime;   fbtnEXTRA := TBitBtn.Create(self);  With fbtnEXTRA do  begin    Top := 10;    Left := 10;    Width := 80;    Height := 80;    Caption := '';    Layout := blGlyphTop;    Parent := Self;    Glyph.Assign(fImage);  end;   SetInitialBounds(0, 0, 100, 100);end; Destructor TMytestbtn.Destroy;begin  fImage.Free;  inherited Destroy;end; procedure TMytestbtn.SetImage(aValue : TBitmap);begin  fImage.Assign(aValue);  if fbtnEXTRA <> nil then    fbtnEXTRA.Glyph.Assign(fImage);  Invalidate;end; procedure Register;begin  RegisterComponents('Misc', [TMytestbtn]);end; end. ---------------------------------------------------------------------- pcurtis · 2021-11-23 07:42 I tried this but the Bitbtn just flashes  (locked in a loop) 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 mytestbtn; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, LResources, Forms, Controls, Graphics, ExtCtrls, Dialogs, Buttons,  lclintf; type  TMytestbtn = class(TCustomControl)    private      FGlyph: TBitmap;      fbtnEXTRA : TBitBtn;      procedure GlyphChanged(Sender: TObject);      function IsGlyphStored: Boolean;    procedure SetGlyph(AValue: TBitmap);    protected      procedure Paint; override;    public      constructor Create(AOwner: TComponent); override;      destructor Destroy; override;    published      property Glyph: TBitmap read FGlyph write SetGlyph stored IsGlyphStored;    end;   procedure Register; implementation constructor TMytestbtn.Create(AOwner : TComponent);begin  inherited Create(AOwner);  FGlyph := TBitmap.Create;FGlyph.OnChange := @GlyphChanged;   Color := clLime;   fbtnEXTRA := TBitBtn.Create(self);  With fbtnEXTRA do  begin    Top := 10;    Left := 10;    Width := 80;    Height := 80;    Caption := '';    Layout := blGlyphTop;    Parent := Self;  end;   SetInitialBounds(0, 0, 100, 100);end; Destructor TMytestbtn.Destroy;begin  FGlyph.Free;  inherited Destroy;end; procedure TMytestbtn.GlyphChanged(Sender: TObject);begin  Invalidate;end; function TMytestbtn.IsGlyphStored: Boolean;begin  Result := not FGlyph.Empty;end; procedure TMytestbtn.Paint;begin  inherited Paint;  fbtnEXTRA.Glyph.Assign(FGlyph);end; procedure TMytestbtn.SetGlyph(AValue: TBitmap);begin  FGlyph.Assign(AValue);end; procedure Register;begin  RegisterComponents('Misc', [TMytestbtn]);end; end. ---------------------------------------------------------------------- pcurtis · 2021-11-24 07:14 Cheers.