This page was last modified 10:22, 20 May 2008.
CS000970 - Sending custom message between views
From Forum Nokia Wiki
| ID | CS000970 | Creation date | May 20, 2008 |
| Platform | S60 3rd Edition, MR | Tested on devices | Nokia N95 |
| Category | Symbian C++ | Subcategory | Code Examples |
| Keywords (APIs, classes, methods, functions): CAknViewAppUi |
Overview
The following example shows how to send custom messages from CAknView to another CAknView while activating the view.
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.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Nokia 30 and MMS | jeatshyan | Nokia M2M | 4 | 2004-02-09 16:54 |
| Inbox | namak | Symbian Networking & Messaging | 1 | 2008-01-31 11:16 |
| adding custom controls to a form in runtime | Atyauristen | Symbian User Interface | 0 | 2002-10-11 07:34 |
| Picture Message Query!! | Priju Jacob Paul | General Symbian C++ | 16 | 2007-05-21 17:34 |
| help on sending sms. | vasant21 | Symbian Networking & Messaging | 2 | 2006-07-18 11:44 |

