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);
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
}
};
}