Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User Abhishek_karmakar's Avatar
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152
    hello everyone,

    i was trying to understand the switching of the views. I created 2 views derived from CAknView and two controls from CcoeControl .compiles properly but does not executes.

    when i debug them it debugs well before ActivateL() of CMyViewSwitchingContainer::ConstructL(const TRect& aRect). but terminates after that.

    can anyone please help.

    following is the list of the followng parts of the program.

    MyViewSwitchingAppUi.cpp
    Code:
    /*
     ============================================================================
     Name		: MyViewSwitchingAppUi.cpp
     Author	  : Abhishek karmakar
     Copyright   : copyright @ a.karmakar			
     Description : CMyViewSwitchingAppUi implementation
     ============================================================================
     */
    
    // INCLUDE FILES
    #include <viewcli.h>
    #include <aknviewappui.h>
    #include <avkon.hrh>
    #include <aknmessagequerydialog.h>
    #include <aknnotewrappers.h>
    #include <stringloader.h>
    #include <f32file.h>
    #include <s32file.h>
    #include <hlplch.h>
    
    #include <MyViewSwitching_0xEB4DB8EB.rsg>
    
    #include "MyViewSwitching_0xEB4DB8EB.hlp.hrh"
    #include "MyViewSwitching.hrh"
    #include "MyViewSwitching.pan"
    #include "MyViewSwitchingApplication.h"
    #include "MyViewSwitchingAppUi.h"
    #include "MyViewSwitchingAppView.h"
    
    _LIT(KFileName, "C:\\private\\EB4DB8EB\\MyViewSwitching.txt");
    _LIT(KText, "Messege text from A.karmakar");
    
    // ============================ MEMBER FUNCTIONS ===============================
    	void CMyViewSwitchingAppUi::ConstructL()
    		{
    		BaseConstructL(CAknAppUi::EAknEnableSkin);
    
    			CEikStatusPane* sp = StatusPane();
    			iNaviPane = (CAknNavigationControlContainer*) sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
    			iDecoratedTabGroup = iNaviPane->ResourceDecorator();
    			if (iDecoratedTabGroup)
    				{
    				iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
    				}
    			// Initialise app UI with standard value.
    
    
    			CMyViewSwitchingAppView* view1 = new(ELeave) CMyViewSwitchingAppView;
    			CleanupStack::PushL(view1);
    			view1->ConstructL(iTabGroup);
    			AddViewL(view1);
    			CleanupStack::Pop(view1);
    
    			iViewId1 = view1->Id();
    			CMyViewSwitchingView2* view2 = new(ELeave) CMyViewSwitchingView2;
    			CleanupStack::PushL(view2);
    			view2->ConstructL();
    			AddViewL(view2);
    			CleanupStack::Pop(view2);
    			iViewId2 = view2->Id();
    
    			SetDefaultViewL( *view1);
    		
    		}
    	CMyViewSwitchingAppUi::~CMyViewSwitchingAppUi()
    		{
    		delete iDecoratedTabGroup;
    		}
    	void CMyViewSwitchingAppUi::DynInitMenuPaneL(TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
    		{
    		
    		}
    	void CMyViewSwitchingAppUi::HandleCommandL(TInt aCommand)
    		{
    		switch (aCommand)
    				{
    				case EEikCmdExit:
    					{
    					Exit();
    					break;
    					}
    					// You can add your all application applying commands here.
    					// You would handle here menu commands that are valid for all views.
    				}
    		
    		}
    	 TKeyResponse CMyViewSwitchingAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
    		{
    		if ( iTabGroup == NULL )
    		        {
    		        return EKeyWasNotConsumed;
    		        }
    
    		    TInt active = iTabGroup->ActiveTabIndex();
    		    TInt count = iTabGroup->TabCount();
    
    		    switch ( aKeyEvent.iCode )
    		        {
    		        case EKeyLeftArrow:
    		            if ( active > 0 )
    		                {
    		                active--;
    		                iTabGroup->SetActiveTabByIndex( active );
    		                // ActivateLocalViewL() is used to change the view.
    		                // To change view from another application we would use ActivateViewL()
    		                // Send an empty message
    		                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
    		                }
    		            break;
    		        case EKeyRightArrow:
    		        
    		            if( (active + 1) < count )
    		                {
    		                active++;
    		                iTabGroup->SetActiveTabByIndex( active );
    		                // ActivateLocalViewL() is used to change the view.
    		                // To change view from another application we would use ActivateViewL()
    		                ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
    		                }
    		            break;
    		        default:
    		            return EKeyWasNotConsumed;
    		        }
    
    		    return EKeyWasConsumed;
    		
    		}
    	void CMyViewSwitchingAppUi::HandleForegroundEventL(TBool aForeground)
    		{
    		if (aForeground==TRUE)
    		    iEikonEnv->InfoMsg(_L("Foreground true"));
    		    else
    		    iEikonEnv->InfoMsg(_L("Foreground false"));
    		
    		}
    	 void CMyViewSwitchingAppUi::HandleResourceChangeL(TInt aType)
    		{
    		CAknAppUi::HandleResourceChangeL( aType );
    
    		    // ADDED FOR SCALABLE UI SUPPORT
    		    // *****************************
    		    if ( aType==KEikDynamicLayoutVariantSwitch )
    		        {
    				((CMyViewSwitchingAppView*) View( iViewId1) )->HandleClientRectChange(  );
    				((CMyViewSwitchingView2*) View( iViewId2) )->HandleClientRectChange(  );
    				}
    		    
    		}
    the debugger takes me to these classes ..

    Code:
    /*
     ============================================================================
     Name		: MyViewSwitchingAppView.cpp
     Author	  : Abhishek karmakar
     Copyright   : copyright @ a.karmakar			
     Description : Application view implementation
     ============================================================================
     */
    
    #include "MyViewSwitchingView2.h"
    #include  "MyViewSwitchingContainer.h" 
    #include  "MyViewSwitching.hrh"
    // INCLUDE FILES
    #include  <aknviewappui.h>
    #include  <avkon.hrh>
    #include <coemain.h>
    #include <aknview.h>
    #include "MyViewSwitchingAppView.h"
    #include <MyViewSwitching_0xEB4DB8EB.rsg>
    
    
    
    // ============================ MEMBER FUNCTIONS ===============================
    void CMyViewSwitchingAppView::ConstructL(CAknTabGroup* aTabGroup)
    	{
    	BaseConstructL(R_MYVIEW_VIEW1);
    	//BaseConstructL(R_MYVIEW_VIEW1);
    	iTabGroup = aTabGroup;
    
    	}
    
    CMyViewSwitchingAppView::~CMyViewSwitchingAppView()
    	{
    	if (iContainer)
    		{
    		AppUi()->RemoveFromViewStack( *this, iContainer);
    		}
    	delete iContainer;
    	}
    
    TUid CMyViewSwitchingAppView::Id() const
    	{
    	return KViewId;
    	}
    
    void CMyViewSwitchingAppView::HandleCommandL(TInt aCommand)
    	{
    	switch (aCommand)
    		{
    		case EAknSoftkeyOk:
    			{
    			iEikonEnv->InfoMsg(_L("view 1 ok"));
    			}
    			break;
    		case EAknSoftkeyExit:
    			{
    			AppUi()->HandleCommandL(EEikCmdExit);
    			}
    			break;
    		case EMyViewCmdView1Cmd1:
    			{
    			
    			}
    			break;
    		case EMyViewCmdView1Cmd2:
    			{
    			
    			}
    			break;
    		case EMyViewCmdView1Cmd3:
    			{
    			
    			}
    			break;
    		default:
    			{
    			
    			}
    			break;
    		}
    	}
    void CMyViewSwitchingAppView::HandleClientRectChange()
    	{
    	if (iContainer)
    		{
    		iContainer->SetRect(ClientRect());
    		}
    	}
    void CMyViewSwitchingAppView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
    	{
    	if (!iContainer)
    		{
    		iContainer = new (ELeave) CMyViewSwitchingContainer;
    		iContainer->SetMopParent(this);
    		iContainer->ConstructL(ClientRect());
    		AppUi()->AddToStackL(*this, iContainer);
    		}
    
    	}
    
    void CMyViewSwitchingAppView::DoDeactivate()
    	{
    	if (iContainer)
    		{
    		AppUi()->RemoveFromViewStack(*this, iContainer);
    		}
    	delete iContainer;
    	iContainer = NULL;
    	}
    AND THE CONTAINER

    Code:
    /*
     ============================================================================
     Name		: MyViewSwitchingContainer.cpp
     Author	  : Abhishek karmakar
     Version	 : 1.0
     Copyright   : copyright @ a.karmakar			
     Description : CMyViewSwitchingContainer implementation
     ============================================================================
     */
    
    #include "MyViewSwitchingContainer.h"
    
    #include <eiklabel.h>
    
    void CMyViewSwitchingContainer::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	
    	iLabel = new (ELeave) CEikLabel;
    	iLabel->SetContainerWindowL(*this);
    	iLabel->SetTextL(_L("This is my View 1"));
    
    	SetRect(aRect);
    
    	ActivateL();
    
    	}
    
    CMyViewSwitchingContainer::~CMyViewSwitchingContainer()
    	{
    	delete iLabel;
    	}
    
    //function from the base classes	
    
    void CMyViewSwitchingContainer::SizeChanged()
    	{
    	iLabel->SetExtent(TPoint(10,10),iLabel->MinimumSize());
    	}
    
    TInt CMyViewSwitchingContainer::CountComponentControls() const
    	{
    	return 1;
    
    	}
    
    CCoeControl* CMyViewSwitchingContainer::ComponentControls(int aIndex) const
    	{
    	switch(aIndex)
    		{
    		case 0:
    			return iLabel;
    		case 1:
    			return NULL;
    		}
    	return NULL;
    	}
    
    void CMyViewSwitchingContainer::Draw(const TRect& aRect) const
    	{
    	CWindowGc& gc = SystemGc();
    	gc.SetPenStyle(CGraphicsContext::ENullPen);
    	gc.SetBrushColor(KRgbBlue);
    	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    	gc.DrawRect(aRect);
    	
    	}
    
    void CMyViewSwitchingContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    	{
    	
    
    	}

    please help..
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  2. #2
    Registered User sriky27's Avatar
    Join Date
    Dec 2005
    Posts
    1,236
    Hi,

    Try in your constructl i.e

    void CMyViewSwitchingContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL(*this);
    iLabel->SetTextL(_L("This is my View 1"));
    iLabel->SetExtent(TPoint(10,10),iLabel->MinimumSize());


    SetRect(aRect);

    ActivateL();

    }
    Regards,
    Sriky

  3. #3
    Registered User Abhishek_karmakar's Avatar
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152
    hey sriky27,

    Thanks for the reply but it is not working for me . It simple exits as soon as i execute the application. there is a example shipped with S60 library "MyView" it is doing the same but in my application it is not working.

    any more ideas

    thanks
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  4. #4
    Registered User yogpan's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    1,043
    Hi,
    Have you tried debugging your application.your implementation looks fine.Are you getting any panic code when your application is crashing??
    Maximus
    S60 Developer
    Impossible is nothing

  5. #5
    Registered User Abhishek_karmakar's Avatar
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152
    hello YogPan,
    thanks to you too. I tried debugging it , after a bit of research i also commented the portions where it was activating the control,Then, i commented the second view construction in my AppUi, now its showing two tabs in the screen the first one being empty and transparent and when i switch the second view it shows me the second view with the container.
    what i am not able to understand is that even when i have commented my second view why is it showing me the display ..

    neways .i'll take it from here . thanks for the replies .. may Nokia bless u all with better SDK's and IDE's.

    (ha ha ha) kidding

    Abhishek karmakar
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

Similar Threads

  1. Does carbide c++ have a new wizard create project based on Avkon View Architecture?
    By weiyiwei in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-04-28, 08:43
  2. Multi View problem
    By hendrawan.ashari in forum Symbian C++
    Replies: 3
    Last Post: 2008-02-27, 06:02
  3. Store and view own WAP sites on Nokia 7650 problem
    By renzo_gsm in forum Browsing and Mark-ups
    Replies: 6
    Last Post: 2003-04-29, 06:22
  4. about view architecture
    By happy_yly in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-04-23, 11:40
  5. Replies: 0
    Last Post: 2003-03-05, 00:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved