×
Namespaces

Variants
Actions
(Difference between revisions)

Implementing a custom CAknQueryDialog dialog

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Adding missing translation link)
 
(9 intermediate revisions by one user not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Touch UI]][[Category:UI]][[Category:S60 3rd Edition (initial release)]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition FP2]][[Category:S60 5th Edition]][[Category:S60 5th Edition]][[Category:Symbian^3]][[Category:Symbian Anna]][[Category:Nokia Belle]]
__NOEDITSECTION__
+
{{ArticleMetaData <!-- v1.2 -->
{{KBCS}}
+
|sourcecode= [[Media:CustomQueryDialog.zip]]
{{ArticleMetaData
+
|id=CS001165
+
|platform=S60 3rd Edition, S60 5th Edition
+
|devices=Nokia 5800 XpressMusic
+
|category=Symbian C++
+
|subcategory=Touch UI, UI
+
|creationdate=October 31, 2008
+
|keywords=CAknQueryDialog
+
 
+
|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]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia 5800 XpressMusic
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 3rd Edition, S60 5th Edition
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|devicecompatability= All S60 3rd Edition and later
|author=[[User:Tepaa]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= Self-Signed
 +
|capabilities= None
 +
|keywords= CAknQueryDialog
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20081031
 +
|author= [[User:Tepaa]]
 +
<!-- The following are not in current metadata -->
 +
|id= CS001165
 
}}
 
}}
 
 
 
==Overview==
 
==Overview==
  
Line 27: Line 30:
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
 
  
 
==MMP file==
 
==MMP file==
Line 34: Line 36:
  
 
<code cpp>
 
<code cpp>
CAPABILITY None       
+
CAPABILITY None       
  
LIBRARY     avkon.lib
+
LIBRARY avkon.lib
LIBRARY     eikcoctl.lib
+
LIBRARY eikcoctl.lib
LIBRARY     eikdlg.lib
+
LIBRARY eikdlg.lib
LIBRARY     euser.lib  
+
LIBRARY euser.lib  
 
</code>
 
</code>
  
Line 214: Line 216:
  
 
The custom dialog is shown for two seconds.
 
The custom dialog is shown for two seconds.
 
+
<!-- Translation --> [[zh-hans:如何完成自定义的CAknQueryDialog对话框]]
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Touch UI]][[Category:UI]][[Category:Code Snippet]]
+

Latest revision as of 08:59, 18 September 2012

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Device(s): All S60 3rd Edition and later
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: CAknQueryDialog
Created: tepaa (31 Oct 2008)
Last edited: hamishwillee (18 Sep 2012)

Contents

[edit] Overview

This snippet shows how to implement a custom dialog. In this case the dialog acts like an application splash screen. The dialog closes itself after two seconds and the application continues to run.

This snippet can be self-signed.

[edit] MMP file

The following capabilities and libraries are required:

CAPABILITY None       
 
LIBRARY avkon.lib
LIBRARY eikcoctl.lib
LIBRARY eikdlg.lib
LIBRARY euser.lib


[edit] Header file

#include <aknquerydialog.h>
#include <e32std.h>
#include <e32base.h>
#include <eikbtgpc.h>
 
class CSplashScreenDialog : public CAknQueryDialog
{
public: // Construction
CSplashScreenDialog();
virtual ~CSplashScreenDialog();
void PreLayoutDynInitL();
void PostLayoutDynInitL();
TBool OkToExitL(TInt aButtonId);
 
private: // From base classes
void SizeChanged();
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;
void Draw( const TRect& /*aRect*/ ) const;
void SetSizeAndPosition(const TSize &aSize);
 
private: // Internal methods
void CalculatePositionAndSize();
static TInt HideDialog(TAny* aAny);
 
private: // Data
CPeriodic* iPeriodic;
};


[edit] Source file

#include "csplashscreendialog.h"
 
const TInt KShowTime(2000000);
 
CSplashScreenDialog::CSplashScreenDialog()
{
// Closes this dialog after KShowTime 2s
TRAPD(err,
iPeriodic = CPeriodic::NewL(CActive::EPriorityIdle);
);
if (!err)
{
iPeriodic->Start(KShowTime, KShowTime, TCallBack(HideDialog, this));
}
}
 
CSplashScreenDialog::~CSplashScreenDialog()
{
if (iPeriodic)
{
iPeriodic->Cancel();
}
delete iPeriodic;
}
 
void CSplashScreenDialog::PreLayoutDynInitL()
{
CAknQueryDialog::PreLayoutDynInitL();
SetEditableL(EFalse);
}
 
void CSplashScreenDialog::PostLayoutDynInitL()
{
// No CBA buttons
CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
cba->MakeVisible(EFalse);
 
// Calculate position of the dialog
CalculatePositionAndSize();
}
 
TBool CSplashScreenDialog::OkToExitL(TInt /*aButtonId*/)
{
return ETrue;
}
 
TInt CSplashScreenDialog::CountComponentControls() const
{
// No child components in this example
return(0);
}
 
CCoeControl* CSplashScreenDialog::ComponentControl(TInt /*aIndex*/) const
{
// No child components in this example
return NULL;
}
 
void CSplashScreenDialog::CalculatePositionAndSize()
{
// Set full screen
SetExtentToWholeScreen();
}
 
void CSplashScreenDialog::SetSizeAndPosition(const TSize &aSize)
{
CAknQueryDialog::SetSizeAndPosition( aSize );
CalculatePositionAndSize();
}
 
void CSplashScreenDialog::SizeChanged()
{
// Update screen
DrawNow();
}
 
void CSplashScreenDialog::Draw( const TRect& /*aRect*/ ) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbBlack);
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
 
// Clear screen
gc.Clear(Rect());
gc.SetBrushStyle( CGraphicsContext::ENullBrush );
 
// Draw round rect
gc.SetPenStyle( CGraphicsContext::ESolidPen );
gc.SetPenColor(KRgbWhite);
gc.DrawRect(Rect());
 
// TODO: Implement what you need
}
 
TInt CSplashScreenDialog::HideDialog(TAny* aAny)
{
CSplashScreenDialog* self = static_cast<CSplashScreenDialog*>( aAny );
 
// Cancel CPeriodic timer
self->iPeriodic->Cancel();
 
// Closes itself
TRAP_IGNORE(
self->TryExitL(1);
);
return KErrNone;
}


[edit] Custom dialog resurce

RESOURCE DIALOG r_custom_dialog
{
flags = EGeneralQueryFlags;
buttons = R_AVKON_SOFTKEYS_EMPTY;
}


[edit] Running the custom dialog

iSplashScreenDialog = new (ELeave) CSplashScreenDialog();
iSplashScreenDialog->ExecuteLD(R_CUSTOM_DIALOG);
// Execution continues here after dialog has hided itself
iSplashScreenDialog = NULL;


[edit] Postconditions

The custom dialog is shown for two seconds.

This page was last modified on 18 September 2012, at 08:59.
98 page views in the last 30 days.
×