×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    39

    Dialog's methods Draw(), CountComponentControls() not called

    Hi
    I'm trying to dynamically create a dialog, and I need it to behave like a container. The problem is that dialog's functions ComponentControl(), CountComponentControls(), Draw() never get called! Why, and what should I do to make them work?
    Thanx
    ======================================== appui.cpp
    void CBlankAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case EblankCmdAppTest:
    {
    CEikDialog *dialog = new (ELeave) CMyDialog ();
    dialog->ExecuteLD(R_EDIT_RULE_DLG_2);
    break;
    }
    }
    }
    ======================================= dialog
    class CMyDialog : public CEikDialog
    {
    public:
    void PostLayoutDynInitL ();
    void PreLayoutDynInitL ();
    CMyDialog();
    private:
    CCoeControl* ComponentControl (TInt aIndex);
    TInt CountComponentControls();
    void Draw(const TRect &aRect);

    CAknSingleStyleListBox *iListBox;
    CEikEdwin *iEdwin;
    };

    void CMyDialog::PreLayoutDynInitL()
    {
    iEdwin=new (ELeave) CEikEdwin();
    TResourceReader reader2;
    CEikonEnv::Static()->CreateResourceReaderLC( reader2,R_EDWIN );
    iEdwin->ConstructFromResourceL( reader2 );
    CleanupStack::PopAndDestroy();
    iEdwin->SetContainerWindowL( *this );
    iEdwin->MakeVisible (ETrue);
    iEdwin->ActivateL();
    }

    void CMyDialog::Draw(const TRect &aRect) //NOT CALLED
    {

    }

    TInt CMyDialog::CountComponentControls() //NOT CALLED
    {
    return 1;
    }

    CCoeControl* CMyDialog::ComponentControl(TInt aIndex) //NOT CALLED
    {
    switch (aIndex) {
    case 0:
    return iEdwin;
    default:
    return NULL;
    }
    }
    ======================================= .RSS
    RESOURCE DIALOG r_edit_rule_dlg_2
    {
    buttons=R_AVKON_SOFTKEYS_OK_CANCEL;
    flags = EEikDialogFlagFillAppClientRect|EEikDialogFlagWait;
    }

    RESOURCE EDWIN r_edwin
    {
    maxlength=30;
    width=20;
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    thing you want to do must be achieved in other way:

    1) create container derived from CCoeControl in a normal way, put all controls in it and test its functionality in the view

    2) after it will work properly move everything from 2nd stage constructor ConstructL(...) to ConstructFromResourceL(...) function, which will be called when ExecuteLD(..) function of dialog will be called from your code instead of ConstructL(...)

    3) There is one exception, in your ConstructL(...) function you probably call CreateWindowL(...) . Remove it from ConstructFromResourceL(...)!!!!!

    4) derive dialog class from CEikDialog.You must implement only one function, so look on CreateCustomControlL(...). This will be called when unknown resource will be in ExecuteLD(...) function detected!!!

    //------------------------------------------------------------------
    // Name : PreLayoutDynInitL
    //------------------------------------------------------------------
    void CDialogListBox::PreLayoutDynInitL() {
    };
    //------------------------------------------------------------------
    // Name : OkToExitL
    //------------------------------------------------------------------
    TBool CDialogListBox::OkToExitL(TInt aKeyCode) {
    return ETrue;
    };
    //------------------------------------------------------------------
    // Name : CreateCustomControlL
    //------------------------------------------------------------------
    SEikControlInfo CContainerDialog::CreateCustomControlL(TInt aControlType) {
    // blank struct SEikControlInfo
    SEikControlInfo controlInfo;
    // pointer to created control
    controlInfo.iControl = NULL;
    // some unknown stuff
    controlInfo.iFlags = 0;
    controlInfo.iTrailerTextId = 0;
    // vytvoreni controlu
    switch (aControlType) {
    case EContainerControlLBType:
    controlInfo.iControl = new(ELeave) CContainerLB();

    break;
    };
    return controlInfo;
    }


    5)Now create your dialog in the standard way:
    dialog = new(ELeave) CContainerDialog ();
    dialog->ExecuteLD(R_DIALOG_CONTAINER);

    6) The last important thing is how resources looks (type and id are "random" numbers enumerated in hrh file):

    RESOURCE DIALOG r_dialog_container
    {
    buttons = R_AVKON_SOFTKEYS_SELECT_BACK;
    flags = EEikDialogFlagWait;
    items = {
    DLG_LINE {
    type = EContainerControlLBType; // see hrh file
    id = EContainerControlLBID; // see hrh file
    }
    };
    }

    BYE and Nice day
    STeN

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    39
    Thanks STeN, very original and unexpected solution, I'll try it later

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    39
    come on don't believe all that stuff
    ya know where the problem is, lmao you just forgot to make the 2 functions you are complaining const

    and that's that

Posting Permissions

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