×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    59

    Settings list in a dialog

    Is it possible to display settings lists on dailogs?

    I've tried to do it by creating a custom control but I get a BAFL 15 panic when I call ExecuteLD.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    39
    Tricky, but possible. With the help of some guys from forum (thanx) i did it. This may help:

    ************* Dialog.cpp----------------------------------------------------------
    //CAppSettingsDialog is a usual CAknDialog-derived dialog

    SEikControlInfo CAppSettingsDialog::CreateCustomControlL(TInt aControlType) {
    SEikControlInfo controlInfo;
    controlInfo.iControl = NULL;
    controlInfo.iFlags = EEikControlHasEars;
    controlInfo.iTrailerTextId = 0;
    switch (aControlType) {
    case ESettingListBoxContainerControl:
    {
    CMySettingListBox * listbox = new (ELeave) CMySettingListBox ();
    controlInfo.iControl = new(ELeave) CListBoxContainerControl(listbox);
    STATIC_CAST(CListBoxContainerControl*, controlInfo.iControl)->SetContainerWindowL(*this);
    }
    break;
    }
    return controlInfo;
    }

    CAppSettingsDialog::TFormControlTypes CAppSettingsDialog::ConvertCustomControlTypeToBaseControlType(TInt aControlType) const
    {
    switch (aControlType) {
    case ESettingListBoxContainerControl:
    return EPopfieldDerived; //this must be present
    break;
    }
    }

    ********** ListBoxContainerControl----------------------------------------------------------------

    class CListBoxContainerControl : public CCoeControl, MCoeControlObserver
    {
    public:
    void ConstructFromResourceL(TResourceReader& aReader);
    void ConstructL();
    CListBoxContainerControl(CCoeControl* aControl):
    {
    SetComponentsToInheritVisibility();
    iListBox = aControl;
    };
    ~CListBoxContainerControl () { delete iListBox; }

    TInt CountComponentControls() const {return 1;};
    ........................................
    private:
    CCoeControl* iListBox;
    };


    CCoeControl* CListBoxContainerControl::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;
    default:
    return NULL;
    }
    }

    TKeyResponse CListBoxContainerControl::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
    {
    return iListBox->OfferKeyEventL(aKeyEvent, aType);
    }

    void CListBoxContainerControl::ConstructFromResourceL(TResourceReader& aReader)
    {
    //called autonmatically by dialog when creating the control

    TInt link = aReader.ReadInt32(); //read LLINK to listbox
    iListBox->ConstructFromResourceL(link);
    }

    ***************** .Rss ----------------------------------------
    #include "listboxcontainer.rh"

    RESOURCE DIALOG r_app_settings
    {
    title=STRING_appsetting_title;
    buttons=R_AVKON_SOFTKEYS_OK_CANCEL;
    flags=EEikDialogFlagWait|EEikDialogFlagFillAppClientRect;
    form = r_pagesettings1;
    }

    RESOURCE FORM r_pagesettings1
    {
    items=
    {
    DLG_LINE
    {
    type = ESettingListBoxContainerControl;
    id = EPage1SettingListbox;
    control = LISTBOXCONTAINER { listbox = r_page1_connection_settings; };
    }
    };
    }

    RESOURCE AVKON_SETTING_ITEM_LIST r_page1_connection_settings
    {
    flags= EAknSettingItemNumberedStyle;
    initial_number = 1;
    items = {
    AVKON_SETTING_ITEM
    {
    identifier = ESettingTextBinaryConnectDirectly;
    setting_page_resource = r_binary_connect_directly;
    associated_resource = r_binary_connect_directly_texts;
    name = STRING_appsetting_type;
    }

    // ............. set up listbox in a usual way
    };
    }
    .............................

    *************** listboxcontainer.rh --------------------------------
    // a small custom control, which has a link to listbox resource
    enum {
    ESettingListBoxContainerControl = 30647 //any arbitrary value
    };


    STRUCT LISTBOXCONTAINER
    {
    LLINK listbox;
    }
    ************************************************************************

    I have also made multipage dialog with setting listboxes, but had to switch pages the ugly way (otherwise it didn't work):

    void CAppSettingsDialog::PostLayoutDynInitL()
    {
    PageChangedL(EPageSettings1);
    }

    void CAppSettingsDialog::PageChangedL(TInt aPageId)
    {
    TInt lineId;
    switch (aPageId)
    {
    case EPageSettings1: lineId = EPage1SettingListbox; break;
    case EPageSettings2: lineId = EPage2SettingListbox; break;
    case EPageSettings3: lineId = EPage3SettingListbox; break;
    case EPageSettings4: lineId = EPage4SettingListbox; break;
    case EPageSettings5: lineId = EPage5SettingListbox; break;
    }
    // there were 5 pages

    MakeLineVisible (EPage1SettingListbox, EFalse);
    MakeLineVisible (EPage2SettingListbox, EFalse);
    MakeLineVisible (EPage3SettingListbox, EFalse);
    MakeLineVisible (EPage4SettingListbox, EFalse);
    MakeLineVisible (EPage5SettingListbox, EFalse);

    MakeLineVisible (lineId, ETrue);
    }

    (I tried to display like that a normal listbox (CAknSingleStyleListBox etc), but without any success, and finally gave it up)

    Have fun (he he)!

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    59

    Thanks I've got it now

    Its reasonably similar to my own attempt but I think that I was linking the setting list control to the dlg_line incorrectly. Also I wasn't implementing ConvertCustomControlTypeToBaseControlType.

    I found that the layout didn't work very well when I used a form so I'm now just adding the control to a plain dialog. Also, I used the setting list control directly rather than embed it in a container.

    Thanks again for the help, Mark.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    44
    Can you please post an example of what the dialog resource needs to look like? I can't seem to get this going. I think the problem is how I specify the DLG_LINE. I assume the control is AVKON_SETTING_ITEM_LIST but what about the type?

    Thanks.

  5. #5
    Registered User
    Join Date
    Feb 2004
    Posts
    11
    @mark_williams : could you share with your code please?

  6. #6
    Regular Contributor
    Join Date
    Mar 2006
    Location
    India
    Posts
    138

    Cool Re: Settings list in a dialog

    Quote Originally Posted by synov
    Tricky, but possible. With the help of some guys from forum (thanx) i did it. This may help:

    ************* Dialog.cpp----------------------------------------------------------
    //CAppSettingsDialog is a usual CAknDialog-derived dialog

    SEikControlInfo CAppSettingsDialog::CreateCustomControlL(TInt aControlType) {
    SEikControlInfo controlInfo;
    controlInfo.iControl = NULL;
    controlInfo.iFlags = EEikControlHasEars;
    controlInfo.iTrailerTextId = 0;
    switch (aControlType) {
    case ESettingListBoxContainerControl:
    {
    CMySettingListBox * listbox = new (ELeave) CMySettingListBox ();
    controlInfo.iControl = new(ELeave) CListBoxContainerControl(listbox);
    STATIC_CAST(CListBoxContainerControl*, controlInfo.iControl)->SetContainerWindowL(*this);
    }
    break;
    }
    return controlInfo;
    }

    CAppSettingsDialog::TFormControlTypes CAppSettingsDialog::ConvertCustomControlTypeToBaseControlType(TInt aControlType) const
    {
    switch (aControlType) {
    case ESettingListBoxContainerControl:
    return EPopfieldDerived; //this must be present
    break;
    }
    }

    ********** ListBoxContainerControl----------------------------------------------------------------

    class CListBoxContainerControl : public CCoeControl, MCoeControlObserver
    {
    public:
    void ConstructFromResourceL(TResourceReader& aReader);
    void ConstructL();
    CListBoxContainerControl(CCoeControl* aControl):
    {
    SetComponentsToInheritVisibility();
    iListBox = aControl;
    };
    ~CListBoxContainerControl () { delete iListBox; }

    TInt CountComponentControls() const {return 1;};
    ........................................
    private:
    CCoeControl* iListBox;
    };


    CCoeControl* CListBoxContainerControl::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;
    default:
    return NULL;
    }
    }

    TKeyResponse CListBoxContainerControl::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
    {
    return iListBox->OfferKeyEventL(aKeyEvent, aType);
    }

    void CListBoxContainerControl::ConstructFromResourceL(TResourceReader& aReader)
    {
    //called autonmatically by dialog when creating the control

    TInt link = aReader.ReadInt32(); //read LLINK to listbox
    iListBox->ConstructFromResourceL(link);
    }

    ***************** .Rss ----------------------------------------
    #include "listboxcontainer.rh"

    RESOURCE DIALOG r_app_settings
    {
    title=STRING_appsetting_title;
    buttons=R_AVKON_SOFTKEYS_OK_CANCEL;
    flags=EEikDialogFlagWait|EEikDialogFlagFillAppClientRect;
    form = r_pagesettings1;
    }

    RESOURCE FORM r_pagesettings1
    {
    items=
    {
    DLG_LINE
    {
    type = ESettingListBoxContainerControl;
    id = EPage1SettingListbox;
    control = LISTBOXCONTAINER { listbox = r_page1_connection_settings; };
    }
    };
    }

    RESOURCE AVKON_SETTING_ITEM_LIST r_page1_connection_settings
    {
    flags= EAknSettingItemNumberedStyle;
    initial_number = 1;
    items = {
    AVKON_SETTING_ITEM
    {
    identifier = ESettingTextBinaryConnectDirectly;
    setting_page_resource = r_binary_connect_directly;
    associated_resource = r_binary_connect_directly_texts;
    name = STRING_appsetting_type;
    }

    // ............. set up listbox in a usual way
    };
    }
    .............................

    *************** listboxcontainer.rh --------------------------------
    // a small custom control, which has a link to listbox resource
    enum {
    ESettingListBoxContainerControl = 30647 //any arbitrary value
    };


    STRUCT LISTBOXCONTAINER
    {
    LLINK listbox;
    }
    ************************************************************************

    I have also made multipage dialog with setting listboxes, but had to switch pages the ugly way (otherwise it didn't work):

    void CAppSettingsDialog::PostLayoutDynInitL()
    {
    PageChangedL(EPageSettings1);
    }

    void CAppSettingsDialog::PageChangedL(TInt aPageId)
    {
    TInt lineId;
    switch (aPageId)
    {
    case EPageSettings1: lineId = EPage1SettingListbox; break;
    case EPageSettings2: lineId = EPage2SettingListbox; break;
    case EPageSettings3: lineId = EPage3SettingListbox; break;
    case EPageSettings4: lineId = EPage4SettingListbox; break;
    case EPageSettings5: lineId = EPage5SettingListbox; break;
    }
    // there were 5 pages

    MakeLineVisible (EPage1SettingListbox, EFalse);
    MakeLineVisible (EPage2SettingListbox, EFalse);
    MakeLineVisible (EPage3SettingListbox, EFalse);
    MakeLineVisible (EPage4SettingListbox, EFalse);
    MakeLineVisible (EPage5SettingListbox, EFalse);

    MakeLineVisible (lineId, ETrue);
    }

    (I tried to display like that a normal listbox (CAknSingleStyleListBox etc), but without any success, and finally gave it up)

    Have fun (he he)!

    Cool man !!!! that is not nice!!!

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    1

    Smile Re: Settings list in a dialog

    Hello synov ,

    i used your code. But it gives me an error "undefined identifier". I guess I am missing a header file. But i am not able to find out where this macro is defined. Can you tell me how did you use this macro in your code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×