Friday, August 15, 2008

Show CAknWaitDialog Code

Following code can be used to show wait dialog when we dont know how much we need to wait for a particular asynchronous event to happen.

.mmp file
Add the following lib files avkon.lib eikcdlg.lib eikctl.lib

.rss file
Add the following lines for the wait dialog resource
RESOURCE DIALOG WaitDialog
{
flags = EAknWaitNoteFlags | EEikDialogFlagNotifyEsc;
buttons=R_AVKON_SOFTKEYS_CANCEL;
items =
{
DLG_LINE
{
type = EAknCtNote;
id = EGeneralNote;
control = AVKON_NOTE
{
layout = EWaitLayout;
singular_label=" Please Wait...";
animation = R_QGN_GRAF_WAIT_BAR_ANIM;
};
}
};
}

.h file
Include this <aknwaitdialog.h>

The following lines will allow to create a wait dialog.
CAknWaitDialog *iDialog;

Class having this needs to implement MProgressDialogCallback to get the cancel callback.

Method that needs to be overridden is DialogDismissedL.

.cpp file
The following lines will shows a dialog and calls DialogDismissedL when canceled.

iDialog = new(ELeave)CAknWaitDialog(
(REINTERPRET_CAST(CEikDialog**,&iDialog)));
iDialog->SetCallback(this);
iDialog->SetTone( CAknNoteDialog::EConfirmationTone );
iDialog->SetTextL(_L("Download..."));
iDialog->ExecuteLD(WAITDIALOG);

Picture

No comments: