How to use the CAknWaitDialog

This example will demonstate the use of CAknWaitDialog in a typical Symbian C++ source code:

In the mmp file:
LIBRARY        avkon.lib
LIBRARY        eikcdlg.lib
LIBRARY        eikctl.lib


In the header file:
// System Includes
#include <aknprogressdialog.h> // for MProgressDialogCallback

// FORWARD DECLARATIONS
class CAknWaitDialog;

class CMyClass : public CBase,
                 public MTestActiveObjNotifier,
                 public MProgressDialogCallback
    {
    // ...

    private: // From MTestActiveObjNotifier

        /**
         * Get the notification about the connection
         * from the registered CTestActiveObj.
         */
        void NotifyConnection(TInt aError);

    private:// From MProgressDialogCallback

        /**
         * Get's called when a dialog is dismissed.
         */
        void DialogDismissedL(TInt aButtonId);


    // ...
    private: // New functions

        /**
         * Stars the wait dialog.
         * /param aResourceId The dialog resource id.
         */
        void StartWaitDialog(const TDesC& aLabel);

        /**
         * Stops the wait dialog.
         */
        void StopWaitDialog();

    // ...
    private: // Member data

        /**
         * TODO: This is a samle Active Object class,
         * use your AO here.
         * Owned by CMyClass.
         */
        CTestActiveObj* iTestActiveObj;

        /**
         * The wait dialog.
         * Owned by CMyClass.
         */
        CAknWaitDialog* iWaitDialog;


In the cpp file:
// System includes
#include <aknwaitdialog.h> // for CAknWaitDialog


// ----------------------------------------------------------------------------
// CMyClass::~CMyClass()
// Destructor
// ----------------------------------------------------------------------------
//
CMyClass::~CMyClass()
    {
    // ...
    if(iWaitDialog)
        {
        delete iWaitDialog;
        iWaitDialog = NULL;
        }

    if(iTestActiveObj)
        {
        delete iTestActiveObj;
        iTestActiveObj = NULL;
        }
    // ...
    }

// ----------------------------------------------------------------------------
// CMyClass::ConstructL()
// Two phase constructor
// ----------------------------------------------------------------------------
//
void CMyClass::ConstructL()
    {
    // TODO: Register the Active Object here.
    // In this example it'll call the NotifyConnection()
    // after the connection.
    iTestActiveObj = CTestActiveObj::NewL(*this);
    }

// ----------------------------------------------------------------------------
// CMyClass::DialogDismissedL(TInt aButtonId)
// Get's called when a dialog is dismissed.
// ----------------------------------------------------------------------------
//
void CMyClass::DialogDismissedL(TInt /*aButtonId*/)
    {
    // No implementation required.
    }

// ----------------------------------------------------------------------------
// CMyClass::StartWaitDialog(const TDesC& aLabel)
// Stars the wait dialog.
// ----------------------------------------------------------------------------
//
void CMyClass::StartWaitDialog(const TDesC& aLabel)
    {
    if(iWaitDialog)
        {
        delete iWaitDialog;
        iWaitDialog = NULL;
        }

    // For the wait dialog
    iWaitDialog = new (ELeave) CAknWaitDialog(
        REINTERPRET_CAST(CEikDialog**, &iWaitDialog));
    iWaitDialog->SetCallback(this);
    iWaitDialog->SetTextL(aLabel);
    iWaitDialog->ExecuteLD(1);//R_TEST_WAITNOTE);
    }

// ----------------------------------------------------------------------------
// CMyClass::StopWaitDialog()
// Stops the wait dialog.
// ----------------------------------------------------------------------------
//
void CMyClass::StopWaitDialog()
    {
    // For wait dialog
    iWaitDialog->ProcessFinishedL();
    iWaitDialog = NULL;
    }

// ----------------------------------------------------------------------------
// CMyClass::MakeConnection()
// Create a connection.
// ----------------------------------------------------------------------------
//
void CMyClass::MakeConnection()
    {
    // TODO: The below function call is a sample here
    // sending some request to an Active Object
    iTestActiveObj->Connect();

    // Now start the wait dialog.
    StartWaitDialog(_L("Connecting..."));
    }

// ----------------------------------------------------------------------------
// CMyClass::NotifyConnection()
// This will notify when ever a connection happend.
// ----------------------------------------------------------------------------
//
void CMyClass::NotifyConnection(TInt /*aError*/)
    {
    // This is also a sample implementation.

    // Now stop the wait dialog when ever a connectin
    // notification has come.
    StopWaitDialog();
    }Note: You should have a basic understanding of Active Objects and the knowledge of the working of Mixin-class.

 

Retrieved from "http://wiki.forum.nokia.com/index.php/How_to_use_the_CAknWaitDialog"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值