×
Namespaces

Variants
Actions
(Difference between revisions)

Showing a global message query using CAknGlobalMsgQuery

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix links)
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{ArticleMetaData <!-- v1.2 -->
__NOEDITSECTION__
+
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|devices= Nokia N93
|-
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|'''ID''' || &nbsp;
+
|platform= S60 3rd Edition, FP1
|'''Creation date''' || June 13, 2008
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|-
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|'''Platform''' || S60 3rd Edition, FP1
+
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|'''Tested on devices''' || Nokia N93
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|-
+
|keywords= CAknGlobalMsgQuery, StringLoader, CAknGlobalMsgQuery::NewL(), CAknGlobalMsgQuery::ShowMsgQueryL(), StringLoader::LoadLC()
|'''Category''' || Symbian C++
+
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
|'''Subcategory''' || Files/Data
+
|translated-by= <!-- [[User:XXXX]] -->
|}
+
|translated-from-title= <!-- Title only -->
 
+
|translated-from-id= <!-- Id of translated revision -->
 
+
|review-by= <!-- After re-review: [[User:username]] -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|review-timestamp= <!-- After re-review: YYYYMMDD -->
|-
+
|update-by= <!-- After significant update: [[User:username]]-->
|'''Keywords (APIs, classes, methods, functions):''' CAknGlobalMsgQuery, StringLoader, CAknGlobalMsgQuery::NewL(), CAknGlobalMsgQuery::ShowMsgQueryL(), StringLoader::LoadLC()
+
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|}
+
|creationdate= 20080613
 +
|author= [[User:Aknyman]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Files/Data
 +
|id= CS001059
 +
}}
  
 
==Overview==
 
==Overview==
This code snippet shows how to create a global message query <tt>CAknGlobalMsgQuery</tt>. A global message query is constructed by calling NewL() method and is executed using the <tt>ShowMsgQueryL()</tt> method. An active object has to be constructed to handle the dismissal of the dialog. This example uses the generic class <tt>CGlobalQueryHandlerAO</tt> that is also used with other global query code snippets. The class <tt>CGlobalQueryContainer</tt> is used to launch the query and it is also the observer that implements the interface <tt>MGlobalQueryObserver</tt>.  
+
This code snippet shows how to create a global message query {{Icode|CAknGlobalMsgQuery}}. A global message query is constructed by calling the {{Icode|NewL()}} method and is executed using the {{Icode|ShowMsgQueryL()}} method. An active object has to be constructed to handle the dismissal of the dialog. This example uses the generic class {{Icode|CGlobalQueryHandlerAO}} that is also used with other global query code snippets. The class {{Icode|CGlobalQueryContainer}} is used to launch the query and it is also the observer that implements the interface {{Icode|MGlobalQueryObserver}}.  
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
Line 30: Line 35:
  
 
<code>
 
<code>
LIBRARY     cone.lib            //CEikonEnv, CCoeEnv  
+
LIBRARY cone.lib            //CEikonEnv, CCoeEnv  
LIBRARY     avkon.lib          //Avkon resources
+
LIBRARY avkon.lib          //Avkon resources
LIBRARY     CommonEngine.lib    //StringLoader  
+
LIBRARY CommonEngine.lib    //StringLoader  
LIBRARY     euser.lib          //CActive, CleanupStack
+
LIBRARY euser.lib          //CActive, CleanupStack
 
</code>
 
</code>
  
Line 249: Line 254:
  
 
==Postconditions==
 
==Postconditions==
The example code shows how to create a global message query, handle its dismissal and how the active object handler informs an observer class that the dialog has been closed.
+
The example code shows how to create a global message query, handle its dismissal, and how the active object handler informs an observer class that the dialog has been closed.
  
 
==See also==
 
==See also==
  
<!-- [[Showing_a_global_message_query_using_CAknGlobalMsgQuery]] -->
+
<!-- [[Showing a global message query using CAknGlobalMsgQuery]] -->
* [[Showing_a_global_confirmation_query_using_CAknGlobalConfirmationQuery]]
+
* [[Showing a global confirmation query using CAknGlobalConfirmationQuery]]
* [[Showing_a_global_list_query_using_CAknGlobalListQuery]]
+
* [[Showing a global list query using CAknGlobalListQuery]]
* [[Showing_a_global_progress_dialog_using_CAknGlobalProgressDialog]]
+
* [[Showing a global progress dialog using CAknGlobalProgressDialog]]
  
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]]
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:Code Snippet]]

Revision as of 10:39, 5 July 2012

Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
Article
Keywords: CAknGlobalMsgQuery, StringLoader, CAknGlobalMsgQuery::NewL(), CAknGlobalMsgQuery::ShowMsgQueryL(), StringLoader::LoadLC()
Created: aknyman (13 Jun 2008)
Last edited: hamishwillee (05 Jul 2012)

Contents

Overview

This code snippet shows how to create a global message query CAknGlobalMsgQuery. A global message query is constructed by calling the NewL() method and is executed using the ShowMsgQueryL() method. An active object has to be constructed to handle the dismissal of the dialog. This example uses the generic class CGlobalQueryHandlerAO that is also used with other global query code snippets. The class CGlobalQueryContainer is used to launch the query and it is also the observer that implements the interface MGlobalQueryObserver.

This snippet can be self-signed.

MMP file

The following libraries are required:

LIBRARY cone.lib            //CEikonEnv, CCoeEnv 
LIBRARY avkon.lib //Avkon resources
LIBRARY CommonEngine.lib //StringLoader
LIBRARY euser.lib //CActive, CleanupStack


Resource file

.rss

#include <eikon.rh>
#include <avkon.rsg>
#include <avkon.rh>
 
//...
RESOURCE TBUF r_global_query_header_text
{
buf = "<header text here>";
}
 
RESOURCE TBUF r_global_query_message_text
{
buf = "<message text here>";
}

Header files

  • observer interface
#ifndef GLOBALQUERYOBSERVER_H
#define GLOBALQUERYOBSERVER_H
 
class MGlobalQueryObserver
{
public:
//keep these methods short running because they are called
//from within an active object
virtual void ProcessOkOptionL() = 0;
virtual void ProcessCancelOptionL() = 0;
virtual void ProcessDoneOptionL() = 0;
virtual void ProcessSelectedItemL(const TInt aItem) = 0;
};
 
#endif // GLOBALQUERYOBSERVER_H
  • handler active object
#ifndef GLOBALQUERYHANDLERAO_H
#define GLOBALQUERYHANDLERAO_H
 
#include <e32base.h> //CActive
#include "GlobalQueryObserver.h"
 
class CGlobalQueryHandlerAO : public CActive
{
public:
~CGlobalQueryHandlerAO();
static CGlobalQueryHandlerAO* NewL(MGlobalQueryObserver& aObserver);
static CGlobalQueryHandlerAO* NewLC(MGlobalQueryObserver& aObserver);
public:
void StartHandler();
private:
CGlobalQueryHandlerAO(MGlobalQueryObserver& aObserver)
: CActive (EPriorityStandard), iObserver(aObserver){};
void ConstructL();
private: // from CActive
void RunL();
void DoCancel();
private: // data
MGlobalQueryObserver& iObserver;
};
#endif //GLOBALQUERYHANDLERAO_H
  • container / observer
#ifndef GLOBALQUERYCONTAINER_H
#define GLOBALQUERYCONTAINER_H
 
#include <coecntrl.h> // CCoeControl
#include "GlobalQueryObserver.h"
#include <aknglobalmsgquery.h> //CAknGlobalMsgQuery
class CGlobalQueryHandlerAO;
 
class CGlobalQueryContainer : public CCoeControl, MGlobalQueryObserver
{
public:
//...
void MakeExampleQueryL();
public: // from MGlobalQueryObserver
void ProcessOkOptionL();
void ProcessCancelOptionL();
void ProcessDoneOptionL(); //not used
void ProcessSelectedItemL(const TInt aItem); //not used
//...
private:
CGlobalQueryHandlerAO* iQueryHandlerAO;
CAknGlobalMsgQuery* iGlobalMsgQuery;
};
#endif // GLOBALQUERYCONTAINER_H


Source files

  • handler active object
#include "GlobalQueryHandlerAO.h"
#include <avkon.hrh> //EAknSoftkeyOk, EAknSoftkeyCancel, EAknSoftkeyDone
 
CGlobalQueryHandlerAO::~CGlobalQueryHandlerAO() { Cancel(); }
 
void CGlobalQueryHandlerAO::ConstructL()
{
CActiveScheduler::Add(this);
}
 
CGlobalQueryHandlerAO* CGlobalQueryHandlerAO::NewLC(MGlobalQueryObserver& aObserver)
{
CGlobalQueryHandlerAO* self = new (ELeave) CGlobalQueryHandlerAO(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
CGlobalQueryHandlerAO* CGlobalQueryHandlerAO::NewL(MGlobalQueryObserver& aObserver)
{
CGlobalQueryHandlerAO* self = CGlobalQueryHandlerAO::NewLC(aObserver);
CleanupStack::Pop(self);
return self;
}
 
void CGlobalQueryHandlerAO::DoCancel(){}
 
void CGlobalQueryHandlerAO::StartHandler() { SetActive(); }
 
void CGlobalQueryHandlerAO::RunL()
{
if (iStatus == EAknSoftkeyOk)
iObserver.ProcessOkOptionL();
else if(iStatus == EAknSoftkeyCancel)
iObserver.ProcessCancelOptionL();
else if(iStatus == EAknSoftkeyDone)
iObserver.ProcessDoneOptionL();
else
iObserver.ProcessSelectedItemL(iStatus.Int());
 
Cancel();
}
  • container / observer
#include "GlobalQueryContainer.h" //CGlobalQueryContainer
#include "GlobalQueryHandlerAO.h" //CGlobalQueryHandlerAO
#include <GlobalQuery_0xED0C36BE.rsg> //Resources
#include <StringLoader.h> // StringLoader
 
void CGlobalQueryContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
ActivateL();
 
MakeExampleQueryL();
}
 
void CGlobalQueryContainer::MakeExampleQueryL()
{
//start the query handler and show global message query
iQueryHandlerAO = CGlobalQueryHandlerAO::NewL(*this);
iQueryHandlerAO->StartHandler();
 
iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
HBufC* headerText = StringLoader::LoadLC(R_GLOBAL_QUERY_HEADER_TEXT);
HBufC* messageText = StringLoader::LoadLC(R_GLOBAL_QUERY_MESSAGE_TEXT);
 
//show the global message query
iGlobalMsgQuery->ShowMsgQueryL(iQueryHandlerAO->iStatus,
*messageText,
R_AVKON_SOFTKEYS_OK_CANCEL,
*headerText,
KNullDesC);
 
CleanupStack::PopAndDestroy(2); //messageText, headerText
}
 
CGlobalQueryContainer::~CGlobalQueryContainer()
{
//...
delete iQueryHandlerAO;
delete iGlobalMsgQuery;
}
 
void CGlobalQueryContainer::ProcessOkOptionL()
{
//OK pressed, do something
iEikonEnv->InfoWinL(_L("OK"),_L("Pressed"));
}
void CGlobalQueryContainer::ProcessCancelOptionL()
{
//Cancel pressed, do something...
iEikonEnv->InfoWinL(_L("Cancel"),_L("Pressed"));
}
void CGlobalQueryContainer::ProcessDoneOptionL()
{
//not used
}
void CGlobalQueryContainer::ProcessSelectedItemL(const TInt /*aItem*/)
{
//not used
}

Postconditions

The example code shows how to create a global message query, handle its dismissal, and how the active object handler informs an observer class that the dialog has been closed.

See also

82 page views in the last 30 days.
×