Sunday, October 14, 2007

How to change wait note text at runtime

Many a times it is needed to show updates on wait notes. This can be achieved with the following:
The resource file
RESOURCE DIALOG r_waitnote
{
flags = EAknWaitNoteFlags;
buttons = R_AVKON_SOFTKEYS_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtNote;
id = EGeneralNote;
control = AVKON_NOTE
{
layout = EWaitLayout;
singular_label = "Receiving File : %d Bytes";
plural_label ="%d %% Recieved";
imagefile = "z:\\system\data\avkon.mbm";
imageid = EMbmAvkonQgn_note_progress;
imagemask = EMbmAvkonQgn_note_progress_mask;
animation = R_QGN_GRAF_WAIT_BAR_ANIM;
};
}
};
}

Here singular_label is what will be shown as soon as the dialog is executed. To change the label CAknWaitNotes SetTextL function is used.

• Create and Execute the dialog
iDlg = new(ELeave)CAknWaitDialog( (REINTERPRET_CAST(CEikDialog**,&iDlg)));
iDlg->SetTone( CAknNoteDialog::EConfirmationTone );
iDlg->SetCallback( this );
iDlg->SetTextL(_L("Please Wait..."));
iDlg->ExecuteLD(R_WAITNOTE);
• Change label as and when required
_LIT(KFormat,"%d %% Recieved");
str.Format(KFormat,kb);
iDlg->SetTextL(str)

• Dismiss the dialog
if(iDlg)
{
iDlg->ProcessFinishedL();
iDlg = NULL;
}

No comments:

stats counter