Namespaces
Variants
Actions
Revision as of 07:47, 28 September 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Sending custom message between views using Symbian C++

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Remove from Archive?: This article has been marked for removal from archive, for the following reasons:
Looks valid on current versions of Symbian C++ to me!

The following example shows how to send custom messages from CAknView to another CAknView while activating the view.

Article Metadata

Tested with
Devices(s): Nokia N95

Compatibility
Platform(s): S60 3rd Edition, MR

Platform Security
Signing Required: Self-Signed
Capabilities: None

Article
Keywords: CAknViewAppUi
Created: tepaa (14 May 2008)
Last edited: hamishwillee (28 Sep 2012)

Contents

MMP file

The following capabilities and libraries are required:

CAPABILITY NONE
LIBRARY avkon.lib

Header, sending custom message

#include <aknview.h>
const TUid KView1Id = {1};
const TUid KView2Id = {2};
const TUid KCustomMessageUid= {2}; // Your custom message uid
 
public:
void CFirstView::HandleCommandL(TInt aCommand);

Source, sending custom message

void CFirstView::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EOpenSecondView:
{
// Switch to view 2 and send a message Uid and a message
 
// Construct a message to send
TBuf8<255> customMessage;
customMessage.Copy(_L8("Message from firsto view"));
 
// Activate the second view and give the message as a parameter
AppUi()->ActivateLocalViewL(KView2Id, KCustomMessageUid, customMessage);
break;
}
}
default:
{
break;
}

Header, receiving custom message

#include <aknview.h>
#include "CFirstView.h"
 
public:
void CSecondView::DoActivateL(const TVwsViewId& aPrevViewId,
TUid aCustomMessageId, const TDesC8& aCustomMessage);
 
private:
HBufC8* iReceivedMessage;

Source, receiving custom message

void CSecondView::DoActivateL(const TVwsViewId& aPrevViewId,
TUid aCustomMessageId, const TDesC8& aCustomMessage)
{
// Create Container
if (!iContainer)
{
iContainer = new (ELeave) CMyViewContainer2;
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
}
 
 
// 1. Check aCustomMessageId to handle aCustomMessage
// 2. You could check aPrevViewId if you were curious to know
// from where this view was called from.
if (aCustomMessageId==KCustomMessageUid)
{
// TODO: Do something with aCustomMessage
iReceivedMessage = aCustomMessage.AllocL();
}
}

Postconditions

When the second view is activated it can receive a custom message from the previous view.

87 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved