icon on button

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

icon on button

Postby giorgiom » Tue Jan 04, 2005 5:19 am

Hi, i want to load an icon into a canvas speedbutton.
some tips ?
Thanks in advance

Postby Lars » Fri Jan 14, 2005 8:31 am

I guess you would have to convert the icon to a bitmap first. The Delphi unit found below works fine:


Copy I2BCONVE.PAS to your your BCB project folder, rename it to I2BConvert.pas and add it to your BCB project.
When compiling, BCB will automatically create the appropriate header file for interfacing the pascal unit.

It would also be fairly easy to rewrite the unit in C++, since there isn't so much code.

Interface example in BCB5:
Code: Select all

void __fastcall TForm1::Button5Click(TObject *Sender)
    TIcon *pIcon = new TIcon;
    Graphics::TBitmap *pBitmap = new Graphics::TBitmap;

    // Load icon from file
    pIcon->LoadFromFile( ".\\I2B.ICO" );

    // Convert icon to bitmap
    ConvertIcon2Bitmap( pIcon, clWhite, pBitmap );

    // Load bitmap in speedbutton
    SpeedButton1->Glyph = pBitmap;

    delete pIcon;
    delete pBitmap;

Return to Technical

Who is online

Users browsing this forum: No registered users and 14 guests