Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

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

From Wiki
Jump to: navigation, search

Archived.pngArchived: 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
S60 3rd Edition (initial release)
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.

This page was last modified on 28 September 2012, at 04:47.
56 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×