You Are Here:

Community: Wiki

This page was last modified 08:36, 26 November 2007.

How to use the CAknWaitDialog

From Forum Nokia Wiki

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.

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fMMPE5ffileX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxMMPE20fileE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfnTypeZCommunityContentQ qdcZtypeQUqfnTypeZE52esourceQ qdcZtypeQUqfnTypeZWebpageQ qdcZtypeQUqfnTypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZE52esourceQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxfileX qfnZuserE5ftagQSxlibpathX qfnZuserE5ftagQSxmmpX qfnZuserE5ftagQSxresourceX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfnTypeZCommunityContentQ qrdfZtypeQUqfnTypeZE52esourceQ qrdfZtypeQUqfnTypeZWebpageQ qrdfZtypeQUqfnTypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ