SpeedButton and png

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33032
    skippy
    Participant

    Hi,

    I want to use a speed button and load a png into the glyph at runtime. Although I'm able to assign this bitmap at design time, loading it at runtime leads to an error “invalid bitmap”, please see the sample.

    Rgds.

    #39574
    Support
    Keymaster

    Hi

    The glyph property of button is a Bitmap, and you can't just use LoadFromFile.
    Here is a changed code :

    CODE
    uses acPNG;

    {$R *.dfm}

    procedure TForm1.sButton1Click(Sender: TObject);
    var
      Png : TPNGGraphic;
    begin
      Png := TPNGGraphic.Create;
      Png.LoadFromFile(ExtractFilePath(Application.ExeName) + 'TestForm2-48.png');
      sSpeedButton2.Glyph.Assign(Png);
      Png.Free;
    end;

    #39578
    skippy
    Participant

    oops, of course… <img src="style_emoticons//blush.gif” style=”vertical-align:middle” emoid=”:blush:” border=”0″ alt=”blush.gif” />

    Thx for your effort.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.