Hi all,

I created a Choicelist and customised the command buttons in a dialog from resource file.

When i select a particular item, the command button's text should be updated dynamically.

For eg:

When i select item 1, the command button's text should display "Item1".

When i select item 2, the command button's text should display "Item2".



I have written the following code. It is crashing in the handle->SetControlCaptionL(ELoginPwdChangeBtn, KItem1);(highlighted area in the code





//CLoginPwdChangeDialog is inherited from CEikDialog.

void CLoginPwdChangeDialog::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)

{



switch(aEventType)

{

case EEventStateChanged:

{

//CCoeControl* control = this->Control(ELoginPwdChoiceList);

CEikChoiceList* list = reinterpret_cast<CEikChoiceList*>(aControl);

TInt index;

index = list->CurrentItem();

CExampleAppUi* appui = (CExampleAppUi*)(CEikonEnv::Static())->EikAppUi();

CLoginPwdChangeDialog* handle = appui->returnLoginPwdHandle();

//CCoeControl* control = static_cast<CCoeControl*>handle->Control(ELoginPwdChangeBtn);

//handle->dummy();

//CEikCommandButton* button = reinterpret_cast<CEikCommandButton*>(control));

if(index==0)

{

_LIT(KItem1,"Change Password");

handle->SetControlCaptionL(ELoginPwdChangeBtn, KItem1);

//button->SetTextL(KItem1);

iEikonEnv->InfoMsg(KItem1);

}

else if(index==1)

{

_LIT(KItem2,"Change Numeric");

handle->SetControlCaptionL(ELoginPwdChangeBtn, KItem2);

//button->SetTextL(KItem2);

iEikonEnv->InfoMsg(KItem2);

}



else

{

_LIT(KItem3,"Change Symbol");

handle->SetControlCaptionL(ELoginPwdChangeBtn, KItem3);

//button->SetTextL(KItem3);

iEikonEnv->InfoMsg(KItem3);

}

//CExampleAppUi* appui = (CExampleAppUi*)(CEikonEnv::Static())->EikAppUi();

//appui->ChangePwdBtn(index);



break;

}



}



}





RESOURCE DIALOG r_login_pwd_change_dialog

{

title="Login/Password Selection";

buttons=r_login_pwd_change_buttons;

flags=EEikDialogFlagNotifyEsc;//|EEikDialogFlagNoTitleBar;

//margins = r_response_margins;

//flags=EEikDialogFlagWait;

items=

{

DLG_LINE

{

type = EEikCtChoiceList;

id = ELoginPwdChoiceList;

control = CHOICELIST { array_id = r_login_lists; };

}

};

}



RESOURCE DLG_BUTTONS r_login_pwd_change_buttons

{

buttons=

{

DLG_BUTTON

{

id=ELoginPwdChangeOkBtn;

button=CMBUT { txt="OK";};

},

DLG_BUTTON

{

id=ELoginPwdChangeBtn;

button=CMBUT { txt="Change Password"; };

}

};

}



Regards,

Mani.