Topic: How to change button style

I need to change the button style using Script from bsPushButton to bsCommandLink need your help with the following code.

var  myButton : TBitBtn;
var  myImage: TPNGImage;


begin
    myButton := TBitBtn.Create(Form1);
    myImage := TPNGImage.Create;

    try
        myButton.Parent := Form1;
        myButton.Left := 5;
        myButton.Top := 5;
        myButton.Width := 35;
        myButton.height := 35;
        myButton.Hint:='Folder';
        myButton.ShowHint:= True;

        myButton.Style:= 0;        {<---- need to change to bsCommandLink }

        myImage.LoadFromFile('Images\folder.png');

        myButton.Glyph.Width := 30;
        myButton.Glyph.height := 30;
        myButton.Layout := blGlyphTop;
        myButton.Margin := 0;
        myButton.Spacing := 0;
        myButton.Glyph.Canvas.Draw(0,0,myImage);

    finally
        myImage.Free;

    end;
end.
Post's attachments

Attachment icon Buttons.zip 371.24 kb, 415 downloads since 2018-05-16 

Re: How to change button style

TBitBtn class don't have option for that, only TButton class.

Dmitry.

Re: How to change button style

is there a way to hide the border of the TBitBtn button?  I just want to show the image, I'm trying to make the button look like a menu icon so that when ever hover to the image the image will be highlighted. Or do you have another way of doing this? Please Advise.

DriveSoft wrote:

TBitBtn class don't have option for that, only TButton class.

Post's attachments

Attachment icon img_menu.png 13.99 kb, 236 downloads since 2018-05-16 

Re: How to change button style

Check it out

var
    myButton : TSpeedButton;
    myImage: TPNGImage;

begin
    myButton := TSpeedButton.Create(Form1);
    myImage := TPNGImage.Create;

    try
        myButton.Parent := Form1;
        myButton.Flat := true;
        myButton.Left := 5;
        myButton.Top := 5;
        myButton.Width := 48;
        myButton.height := 48;
        myButton.Hint:='Folder';
        myButton.ShowHint:= True;


        myImage.LoadFromFile('Images\folder.png');

        myButton.Glyph.Width := 30;
        myButton.Glyph.height := 30;
        myButton.Layout := blGlyphTop;
        myButton.Margin := 5;
        myButton.Spacing := 0;
        myButton.Glyph.Canvas.Draw(0,0,myImage);

    finally
        myImage.Free;
    end;
end.
Dmitry.

Re: How to change button style

wow!! this works.. thanks.