void CCommonDialogsExSettingsDialog::PreLayoutDynInitL()
    {
    iMemory = CAknMemorySelectionSettingPage::EPhoneMemory;
    iDriveNumber = EDriveC;

    CAknSettingStyleListBox* listBox = 
                            static_cast< CAknSettingStyleListBox* >
                            ( Control( ECommonDialogsExSettingsListboxId ) );
    User::LeaveIfNull( listBox );

    CAknSettingItem* settingItem;
    HBufC* itemTitle;

    // Create the memory selection item
    if ( iMultiDriveSupport )
        {    
        settingItem =
                new( ELeave ) CAknMemorySelectionSettingItemMultiDrive(
                                            iResourceId, iDriveNumber );
        }
    else
        {
        settingItem =
                new( ELeave ) CAknMemorySelectionSettingItem(
                                            iResourceId, iMemory );
        }
    CleanupStack::PushL( settingItem );

    // Set memory selection item's title
    itemTitle = iCoeEnv->AllocReadResourceLC( R_STRING_COMMONDIALOGSEX_SET_MEMORY );
    settingItem->ConstructL( EFalse, 0, *itemTitle, NULL, 0,
                                                    EAknCtPopupSettingList );
    CleanupStack::PopAndDestroy();  // itemTitle

    // Add memo store item to the settings array
    iSettingItemArray.AppendL( settingItem );
    CleanupStack::Pop();    // settingItem

    CTextListBoxModel* model = listBox->Model();
    model->SetItemTextArray( &iSettingItemArray );
    // Ownership retained by us
    model->SetOwnershipType( ELbmDoesNotOwnItemArray );

    iSettingItemArray.RecalculateVisibleIndicesL();
    listBox->CreateScrollBarFrameL( ETrue );
    listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
                        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
    listBox->HandleItemAdditionL();
    listBox->SetListBoxObserver( this );
    listBox->UpdateScrollBarsL();
    }
	virtual class CAknSettingItem* CreateItemL(TInt aId, TInt aOrdinal)
	{
		CALLSTACKITEM_N(_CL("CAutoSettingsImpl"), _CL("CreateItemL") );
		if ( ! iResources )
			Bug( _L("Resources not read") ).Raise();
		
		CAknSettingItem* item = CreateSettingItemL( aId );
		ResourceReaders::CSettingItem* r = iResources->Find( aId );
		if ( ! r )
			{
				Bug( _L("Resource not found for identifier %d in ordinal %d") ).TechMsg( aId, aOrdinal ).Raise();
				return NULL;
			}

		item->SetEmptyItemTextL( r->EmptyItemText() );
		item->SetCompulsoryIndTextL( r->CompulsoryText() );
		item->ConstructL( EFalse, aOrdinal, r->Name(), NULL, r->iSettingPageResource, r->iType, r->iSettingEditorResource, r->iAssociatedResource );
		
		// clumsy and stupid, but 
		LoadSettingL( aId );
		SetItemDataL( aId );
		UpdateSettingItemL( aId );
		return iItems[aId];
	}