Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! err... Loading an icon, dynamically, as a SpeedButton's glyph

Status
Not open for further replies.

tibberous

Programmer
Nov 2, 2006
8
US
I am trying to create a button based off of an icon handle that is loaded at runtime.

I can get the icon to work properly as an Image, but if I try to use it as the glyph of a speed button, it has problems with transparency.

Does anyone know how to do this, with or without the VCL.

Thanks

(btw, Hello to everyone, this is my first post)
 
The transparency applies for the same color as the lower left dot. I have however had problems with 256-colors BMP but by using 16-color BMP it works like a charm.

Totte
Keep making it perfect and it will end up broken.
 
Try this:

TIcon *nwIcon = new TIcon();
Graphics::TBitmap *bmpImage = new Graphics::TBitmap();
try {
nwIcon->LoadFromFile("yourfile.ico");
bmpImage->Width = nwIcon->Width;
bmpImage->Height = nwIcon->Height;
bmpImage->Canvas->Draw(0, 0, nwIcon);
SpeedButton1->Glyph->Assign(bmpImage);
}
__finally
{
nwIcon->Free();
bmpImage->Free();
}

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top