This page was last modified 10:22, 20 May 2008.
CS000970 - Sending custom message between views
From Forum Nokia Wiki
(Redirected from Sending custom message between views)
| 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 |
| about programming in Symbain | basharam | General Symbian C++ | 1 | 2004-09-11 20:54 |
| Unwanted response message | smiliekim | General Messaging | 1 | 2005-02-04 12:46 |
| Sending binary message | Anil_Karam | Mobile Java General | 0 | 2008-02-06 05:27 |
| Sending Picture Message across Telcom/Operator | amber141 | General Messaging | 2 | 2004-05-14 14:59 |
| (Please Help Me)Custom control In a Dialog | praveen.nitdgp@gmail.com | Symbian User Interface | 0 | 2008-02-20 06:12 |

