×
Namespaces

Variants
Actions

Using CAknIconArray to read icons for listbox from resources

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition
S60 2nd Edition (initial release)
S60 1st Edition
Article
Created: User:Technical writer 2 (04 Feb 2004)
Last edited: hamishwillee (14 Jun 2012)

Overview

Using CAknIconArray to read icons for listbox from resources

Description

The Symbian API contains the helper class CAknIconArray that allows reading icons for the listbox from resources. It uses the AKN_ICON_ARRAY structure. Could you provide an example of how this functionality is used?

Solution

Fill in the resource the following way:
RESOURCE AKN_ICON_ARRAY r_icon_testIcons
    {
    type = EAknIconArraySimple;
    bmpfile = "z:\SYSTEM\DATA\AVKON.MBM";
    icons =
        {
        AKN_ICON
            {
            iconId = EMbmAvkonQgn_indi_checkbox_on;
            maskId = EMbmAvkonQgn_indi_checkbox_on_mask;
            },
        AKN_ICON
            {
            IconId = EMbmAvkonQgn_indi_checkbox_off;
            maskId = EMbmAvkonQgn_indi_checkbox_off_mask;
            }
        };
    }
This resource contains the default icons for checkboxes.
In the source code, call CAknIconArray::ConstructFromResourceL() to construct the icons.
...
// CAknSingleGraphicStyleListBox* iListbox;
iListbox = new(ELeave)CAknSingleGraphicStyleListBox();
iListbox->SetContainerWindowL(*this);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, R_LIST);
iListbox->ConstructFromResourceL(reader);
// Creates a GUI icon array.
CAknIconArray* icons =new(ELeave) CAknIconArray(2);
CleanupStack::PushL(icons);
icons->ConstructFromResourceL(R_ICON_TESTICONS);
// Sets graphics as ListBox icon.
iListbox->ItemDrawer()->ColumnData()->SetIconArray(icons);
CleanupStack::Pop(); // icons
CleanupStack::PopAndDestroy(); // reader

This page was last modified on 14 June 2012, at 07:24.
35 page views in the last 30 days.