If the application contains multiple views and they need to
be switched, it can be done in various ways. One of the common ways
is to delete the current view, create a new view, and add the new
one to the control stack. Here, CMyAppUi has
a custom method to change a view. Often a more generic approach should
be favored, but for simplicity the basic idea could be as follows:
void CMyAppUi::ChangeToView2L()
{
CCoeControl* newView = CMyAppView2::NewL(ClientRect());
if(iCurrentView)
{
RemoveFromStack(iCurrentView);
delete iCurrentView;
}
iCurrentView = newView;
AddToStackL(iCurrentView);
}
Although this architecture provides the most flexible way of manipulating different views, the view architecture should be considered. Among other things, it provides a ready framework for doing the essentials in view switching.