×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    error in the MyView application

    Hi!
    In the sample MyView application the i am creating a listbox in the container.cpp .Now i want it in such a way that as soon as i click on the item in the listbox it should open the default Todo application.But this application is activated in the second View's HandleCommandL function.So what i did was that i deleted the case of activating the ToDo from view2 and added it in the view1's HandleCommandL function .I have given My code for MyView Container.cpp and MyViewView.cpp .I am getting an error that

    " illegal use of incomplete struct/union/class CMyViewView" in the container.cpp's HandleListBoxEventL function.
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    MYVIEWCONTAINER.CPP

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    /*
    * ============================================================================
    ============================================================================
    */

    // INCLUDE FILES
    #include "MyViewContainer.h"
    #include <aknviewappui.h>
    #include <eiklabel.h> // for example label control
    #include <StringLoader.h>
    #include <aknappui.h>
    #include <avkon.hrh>
    // ================= MEMBER FUNCTIONS =======================

    _LIT(KListItem, "%d\t%S\t\t");

    _LIT(KItemOne,"ToDo");
    _LIT(KItemSecond, "Vivek");
    _LIT(KItemThird, "Parag");
    _LIT(KItemFourth, "Chepall");
    _LIT(KItemFifth, "Deore");

    CMyViewContainer::CMyViewContainer(CMyViewView& aView)
    : iTodoView(aView)
    {
    }
    CMyViewContainer* CMyViewContainer::NewL( const TRect& aRect,
    CMyViewView& aView)
    {
    CMyViewContainer* self = new (ELeave) CMyViewContainer(aView);
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    CleanupStack::Pop(self);
    return self;
    }

    void CMyViewContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    list = new (ELeave) CAknSingleNumberStyleListBox;
    list->ConstructL(this);
    list->SetContainerWindowL(*this);
    GetItemArray();
    list->SetListBoxObserver(this);
    list->ActivateL();
    list->CreateScrollBarFrameL(ETrue);
    list->ScrollBarFrame()->SetScrollBarVisibilityL(
    CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto );
    SetRect(aRect);
    ActivateL();
    MakeVisible(ETrue);
    }

    // Destructor
    CMyViewContainer::~CMyViewContainer()
    {
    delete list;

    }
    void CMyViewContainer::GetItemArray()
    {

    CDesCArray*itemList = new (ELeave)CDesCArrayFlat(6);
    TBuf<32>item;
    TInt idx=1;
    item.Format(KListItem,idx,&KItemOne);
    itemList->AppendL(item);idx++;
    item.Format(KListItem,idx,&KItemSecond);
    itemList->AppendL(item); idx++;
    item.Format(KListItem,idx,&KItemThird);
    itemList->AppendL(item);idx++;
    item.Format(KListItem,idx,&KItemFourth);
    itemList->AppendL(item);idx++;
    item.Format(KListItem,idx,&KItemFifth);
    itemList->AppendL(item);idx++;
    list->Model()->SetItemTextArray(itemList);
    list->Model()->SetOwnershipType(ELbmOwnsItemArray);


    }

    void CMyViewContainer::SizeChanged()
    {
    list->SetExtent(TPoint(0,0), list->MinimumSize());
    }


    TInt CMyViewContainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

    CCoeControl* CMyViewContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return list;
    /*
    case 1:
    return iToDoLabel;
    case 2:
    return iToDoLabel2;
    */
    default:
    return NULL;
    }
    }

    void CMyViewContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbBlue);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }

    TKeyResponse CMyViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if(list)
    return list->OfferKeyEventL(aKeyEvent, aType);
    else
    return EKeyWasNotConsumed;
    }



    void CMyViewContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/,
    TListBoxEvent aEventType)
    {
    if (aEventType == EEventEnterKeyPressed)
    {
    //CMyViewView2* iToDoView = static_cast<CMyViewView2*>(iAvkonViewAppui);
    iTodoView.HandleCommandL(EMyViewCmdView1Cmd4);

    }
    }

    // End of File
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    THIS IS MY MYVIEWVIEW.CPP
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    /*
    * ============================================================================
    ============================================================================
    */

    // INCLUDE FILES
    #include <aknviewappui.h>
    #include <avkon.hrh>
    #include <MyView.rsg>
    #include "MyViewView.h"
    #include "MyViewContainer.h"
    #include "myview.hrh"


    // ================= MEMBER FUNCTIONS =======================

    void CMyViewView::ConstructL(CAknTabGroup* aTabGroup)
    {
    // construct R_MYVIEW_VIEW1 resources
    BaseConstructL( R_MYVIEW_VIEW1 );
    iTabGroup=aTabGroup;
    }

    CMyViewView::~CMyViewView()
    {
    if ( iContainer )
    {
    AppUi()->RemoveFromViewStack( *this, iContainer );
    }

    delete iContainer;
    }

    TUid CMyViewView::Id() const
    {
    return KViewId;
    }

    void CMyViewView::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case EAknSoftkeyOk:
    {
    iEikonEnv->InfoMsg( _L("view1 ok") );
    break;
    }
    case EAknSoftkeyExit:
    {
    AppUi()->HandleCommandL(EEikCmdExit);
    break;
    }

    case EMyViewCmdView1Cmd1:
    {
    // Update the correct tab in the navipane.
    // View Management System does not adjust the navi pane tabs.
    iTabGroup->SetActiveTabByIndex(1);

    // Switch to view 2
    const TUid KDemo1ViewId = { 2 }; // UID of the second view
    AppUi()->ActivateLocalViewL(KDemo1ViewId);
    break;
    }
    case EMyViewCmdView1Cmd2:
    {
    // Update the correct tab in the navipane.
    // View Management System does not adjust the navi pane tabs.
    iTabGroup->SetActiveTabByIndex(1);

    // Switch to view 2 and send a message Uid. Message is set to null.
    const TUid KDemo1ViewId = { 2 }; // UID of the second view
    const TUid KCustomMessageUid= { 2 }; // MessageUid to send
    AppUi()->ActivateLocalViewL(KDemo1ViewId, KCustomMessageUid, KNullDesC8);
    break;
    }
    case EMyViewCmdView1Cmd3:
    {
    // Update the correct tab in the navipane.
    // View Management System does not adjust the navi pane tabs.
    iTabGroup->SetActiveTabByIndex(1);

    // Switch to view 2 and send a message Uid and a message
    const TUid KDemo1ViewId = { 2 }; // UID of the second view
    const TUid KCustomMessageUid= { 2 }; // MessageUid to send
    // Construct a message to send
    TBuf8<255> customMessage;
    customMessage.Copy(_L8("Some data here"));
    AppUi()->ActivateLocalViewL(KDemo1ViewId, KCustomMessageUid, customMessage);
    break;
    }
    case EMyViewCmdView1Cmd4:
    {
    // Open ToDo Application
    const TUid KToDoUid = { 0x10005900 }; // Application Uid
    const TUid KToDoViewId = { 3 }; // UID the view in the external application

    AppUi()->ActivateViewL(TVwsViewId(KToDoUid, KToDoViewId));
    break;
    }

    default:
    {
    AppUi()->HandleCommandL( aCommand );
    break;
    }
    }
    }

    void CMyViewView::HandleClientRectChange()
    {
    if ( iContainer )
    {
    iContainer->SetRect( ClientRect() );
    }
    }

    void CMyViewView::DoActivateL(
    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
    const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
    {
    iContainer = CMyViewContainer::NewL(ClientRect(),*this);
    iContainer->SetMopParent(this);
    //iContainer->ConstructL( ClientRect() );
    AppUi()->AddToStackL( *this, iContainer );
    }

    // Message handling would take place here.
    }

    void CMyViewView::DoDeactivate()
    {
    if ( iContainer )
    {
    AppUi()->RemoveFromViewStack( *this, iContainer );
    }

    delete iContainer;
    iContainer = NULL;
    }
    /*
    void CMyViewView::CallView2()
    {
    itodoview.HandleCommandL(EMyViewCmdView2Cmd1);
    }
    */
    // End of File

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    If any body could solve my problem i will be thankful cause its very frustrating.


    Vivek

  2. #2
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: error in the MyView application

    hi,

    u need to inherit a MEikListBoxObserver and HandleListBoxEventL for observing events the list.

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  3. #3
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: error in the MyView application

    hi,

    u need to inherit a MEikListBoxObserver and HandleListBoxEventL for observing events on the list.

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  4. #4
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    Hi!
    Thanks (Mateen)for replying .My CMyView container class is inherited from MEikListBoxObserver and i have also declared that function (HandleListBoxEventL)in my container.h file.Is that what you wanted to say

  5. #5
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: error in the MyView application

    hi,

    This is wht i meant to say

    void CContainer::LoadSelectedOption()
    {

    TInt iViewId(0);



    optionSelected = iGamesGrid->CurrentDataIndex();

    switch(optionSelected)
    {
    case View1:
    iViewId = E1;
    break;
    case View2:
    iViewId = E2;
    break;

    }

    iView->HandleCommandL(iViewId);
    }


    void CContainer::HandleListBoxEventL(CEikListBox* , TListBoxEvent aListBoxEvent)
    {

    if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
    (aListBoxEvent == MEikListBoxObserver::EEventItemClicked))
    {
    LoadSelectedOption();
    }
    }

    The cases in the LoadSelectedOption is switched with the commands E1,E2 and soon and for each command is handled in its view for switching.

    Debug by putting a break point at LoadSelectedOption()

    and check whether ur able to control the events of lists.

    I hope this is much clear now

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  6. #6
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    hI!
    ya i got your point ,but i could'nt understand that iGamesGrid->CurrentDataIndex() ,exactly what it does and can i use it directly or does it require any changes or any predeclarations,and once again thanks for replying .

    Vivek

  7. #7
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: error in the MyView application

    hi,

    i used grid in my application that's y i took
    iGamesGrid->CurrentDataIndex()

    ur using list so take the current index of the list.

    Regards,
    Mateen Maldar
    "Whatever the mind can conceive and believe, the mind can achieve"

  8. #8
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    hi!
    I am confused about the assignment of optionSelected .Can you please go through my code of Container.cpp and indicate where and what changes should i do ,I will be very very thankful to you.Please

    Vivek

  9. #9
    Super Contributor
    Join Date
    Aug 2005
    Location
    india
    Posts
    2,078

    Re: error in the MyView application

    hi,

    sorry dude , we are here for the forum to help people where they are wrong in their program code,we are not a review board ok.

    Check ur code ,debug it and try to know where ur wrong.

    This is technical assistant forum. ok and plz don't send codes to personal email ids.

    paste ur code so that others can reply u. ok.

    Regards,
    Mateen Maldar
    Last edited by mateen_maldar; 2006-07-03 at 07:34.
    "Whatever the mind can conceive and believe, the mind can achieve"

  10. #10
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    ya allright i am sorry for that but thanks for your help

    vivek

  11. #11
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    Hi!
    Actually i was a little bit of frustrated so i wanted the things to come easy ,but any way if you don't mind can ask you a simple thing ,is that in the code you send iView->HandleCommandL(iViewId) how should be the declaration of iView .

    Thanks
    Vivek

  12. #12
    Super Contributor
    Join Date
    May 2005
    Location
    Hyderabad,India
    Posts
    704

    Re: error in the MyView application

    Hi,

    just go through the multiviews example in SDK. or do like this,

    void container::SetView(CxxxView *aView)
    {iView=aView;}

    and in view's DoActivateL(),

    iContainer = new (ELeave)CMyViewContainer;
    iContainer->SetMopParent(this);
    iContainer->ConstructL( ClientRect() );
    iContainer->SetView(this);
    AppUi()->AddToStackL( *this, iContainer );

    regards,
    eswar

  13. #13
    Regular Contributor
    Join Date
    May 2006
    Posts
    141

    Re: error in the MyView application

    HI!
    Thanks for your reply i will go through the multiview example in the SDK and also try to implement it your way

  14. #14
    Registered User
    Join Date
    Apr 2006
    Posts
    47

    Re: error in the MyView application

    this solution has limited container to be used only with view framework. what about dialogs? caknviewappui has capability to return uid of currently focused view. use returned uid to retrieve caknview derived object and inform it about event (handlecommand).

Similar Threads

  1. Auto Start of the application
    By S.S.Sudhakar in forum Symbian
    Replies: 19
    Last Post: 2008-09-25, 02:16
  2. Java Application Provisioning ove BT
    By a_n_k_u_r in forum Bluetooth Technology
    Replies: 3
    Last Post: 2006-06-23, 08:48
  3. Replies: 0
    Last Post: 2005-05-28, 10:20
  4. Replies: 0
    Last Post: 2003-12-03, 10:18
  5. Replies: 0
    Last Post: 2003-02-03, 08:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •