Board index » cppbuilder » Convert TPicture->Bitmap to TPicture->Icon

Convert TPicture->Bitmap to TPicture->Icon

Hi,

I tried to convert a modified Picture of TBitmap (32x32 with 16 colours)
into a TIcon (32x32 with 16 colours), because I want to display this into
the Icon-ToolBar at the right, bottom site.
I have to realise following: The Icon at the IconToolBar should display 4
LED's with different colours and system situations. I have to modified each
LED separately during working process.

Best regards,
Michael

 

Re:Convert TPicture->Bitmap to TPicture->Icon


Hi Michael,

Quote
> I tried to convert a modified Picture of TBitmap (32x32 with 16 colours)
> into a TIcon (32x32 with 16 colours), because I want to display this into
> the Icon-ToolBar at the right, bottom site.
> I have to realise following: The Icon at the IconToolBar should display 4
> LED's with different colours and system situations. I have to modified each
> LED separately during working process.

You can use a TImageList to convert a TBitmap to a TIcon...

#include <memory>

    std::auto_ptr<Graphics::TBitmap> Bitmap
        (new Graphics::TBitmap());
    Bitmap->Width = GetSystemMetrics(SM_CXSMICON);
    Bitmap->Height = GetSystemMetrics(SM_CYSMICON);
    Bitmap->Canvas->Font->Size = 8;
    Bitmap->Canvas->TextOut(0, 0, "123");

    std::auto_ptr<TImageList> ImageList
        (new TImageList(NULL));
    ImageList->Width = Bitmap->Width;
    ImageList->Height = Bitmap->Height;
    ImageList->Add(Bitmap.get(), NULL);

    MyIcon = new TIcon();
    ImageList->GetIcon(0, MyIcon);

HTH.

--
Damon Chandler
http://bcbcaq.freeservers.com

Other Threads