Changing Title Pane Text
Article Metadata
The code below shows how to change the Title Pane Text.
Headers required:
#include <akntitle.h> // CAknTitlePane
#include <eikspane.h> // CEikStatusPane ,CEikStatusPaneBase
Library required:
LIBRARY avkon.lib //CAknTitlePane
LIBRARY eikcoctl.lib //CEikStatusPane ,CEikStatusPaneBase
Source file:
TUid titlePaneUid;
titlePaneUid.iUid = EEikStatusPaneUidTitle;
// calling CAknAppUi::StatusPane() which returns CEikStatusPane* //
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane = statusPane->PaneCapabilities(titlePaneUid);
// if title pane is accessible //
if ( subPane.IsPresent() && subPane.IsAppOwned() )
{
CAknTitlePane* titlePane =
(CAknTitlePane*) statusPane->ControlL(titlePaneUid);
// read the title text from the resource file
HBufC* titleText = StringLoader::LoadLC(R_TITLE_TEXT);
// set the title pane's text
titlePane->SetTextL(*titleText);
CleanupStack::PopAndDestroy(titleText);
}


// a patched verison, which does not include subPane declaration // because CEikStatusPaneBase::TPaneCapabilities is an // inner class, it is not supposed to be declare as // an automatic in the function (causing problem). // And the TUid titlePaneUid is updated to TPaneId // although they are actually the same by #define, // the strongly typed compiler may have warning.
void CUi::ChangeTitle()
{ TPaneId titlePaneUid; CEikStatusPane * statusPane; // peter: subPane = xxx model is doing memory copy// original: // if ( subPane.IsPresent() && subPane.IsAppOwned()... ) if ( statusPane->PaneCapabilities(titlePaneUid).IsPresent() && statusPane->PaneCapabilities(titlePaneUid).IsAppOwned() ) { HBufC* titleText; CAknTitlePane* titlePane ;titlePane = (CAknTitlePane*) statusPane->ControlL(titlePaneUid); // read the title text from the resource file titleText = StringLoader::LoadLC(R_TITLE_MAIN); // set the title pane's text titlePane->SetTextL(*titleText); CleanupStack::PopAndDestroy(titleText); } }