TIconAssignTo (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Language:

Description

This example demonstrates the use of the AssignTo method of the TIcon class to copy the image stored in an icon to a bitmap.

Code

__fastcall TMainForm::TMainForm(TComponent* Owner)
        : TForm(Owner)
{
        TIcon* icon;
        Graphics::TBitmap* bmp;
 
        /* Create an icon and load it from file. */
        icon = new TIcon();
        icon->LoadFromFile("..\\test_icon.ico");
 
        /* Create a bitmap from the loaded icon. */
        bmp = new Graphics::TBitmap();
        icon->AssignTo(bmp); // Equivalent to: Bmp.Assign(Icon)
 
        /* Assign the bitmap to the image on the form. */
        Image1->Picture->Assign(bmp);
 
        /* Free the intermediary objects. */
        delete icon;
        delete bmp;
}

Uses

Personal tools