×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    3

    open a view by clicking the listbox item

    hi

    when i click a list box item i want to show details in a view

    i have written the code


    Switchcontainer.cpp

    void CSwitchContainer::HandleListBoxEventL(CEikListBox *aListBox, TListBoxEvent aEventType)
    {

    if(aEventType == EEventItemClicked)
    {
    AppUi()->HandleCommandL(ESwitchCmdAppView2);
    }
    }

    ******************************
    SwitchAppUi.cpp

    void CSwitchAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case ESwitchCmdAppView2:
    {
    ActivateLocalViewL(TUid::Uid(ESwitchView2Tab));
    break;
    }
    // TODO: Add Your command handling code here

    default:
    break;
    }
    }



    i get the error

    Switchcontainer.cpp
    C:\AMBADAS\SWITCH\SRC\Switchcontainer.cpp(198) : error C2065: 'AppUi' : undeclared identifier
    C:\AMBADAS\SWITCH\SRC\Switchcontainer.cpp(198) : error C2227: left of '->HandleCommandL' must point to class/struct/union
    Error executing cl.exe.




    pl tell me what is the reason for this error

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Beijing
    Posts
    3,609
    Hi,

    AppUi() is a member function of CAknView. If your container is derived from CCoeControl, then it does not have this API. This is why it does not work for you. Please check your code, or post your code here. In this case, I can help you to solve your problem.

    Liuxg
    Forum Nokia

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    3

    my code is as follows

    i also want to take the seleected item id to the view

    SWitchContainer.h

    #ifndef SWITCHCONTAINER_H
    #define SWITCHCONTAINER_H

    // INCLUDES
    #include <coecntrl.h>
    #include <eiklbo.h>
    // FORWARD DECLARATIONS
    class CEikLabel; // for example labels
    class CEikTextListBox;
    class CEikColumnListBox;
    // CLASS DECLARATION

    class CSwitchContainer : public CCoeControl,MEikListBoxObserver// MCoeControlObserver
    {
    public: // Constructors and destructor

    /**
    * EPOC default constructor.
    * @param aRect Frame rectangle for container.
    */
    void ConstructL(const TRect& aRect);

    /**
    * Destructor.
    */
    ~CSwitchContainer();

    public: // New functions

    public: // Functions from base classes
    int InitListBox();
    CEikColumnListBox *iListBox;
    void HandleListBoxEventL(CEikListBox *aListBox, TListBoxEvent aEventType);
    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
    TBuf<100> TmpNm;
    private: // Functions from base classes


    void SizeChanged();


    TInt CountComponentControls() const;

    CCoeControl* ComponentControl(TInt aIndex) const;

    void Draw(const TRect& aRect) const;

    private: //data

    CEikLabel* iLabel; // example label
    CEikLabel* iToDoLabel; // example label
    };

    #endif

    // End of File
    *************************************************************************************************************************************************
    Switchcontainer.cpp

    // INCLUDE FILES
    #include "SwitchContainer.h"

    #include <eiktxlbx.h>
    #include <barsread.h>
    #include <coemain.h>
    #include "Switch.rsg"
    #include "Switch.hrh"

    #include <d32dbms.h>
    #include <eiklbv.h>
    #include <aknnotewrappers.h>
    #include <akndialog.h>
    #include <aknlists.h>
    #include <eikclb.h>
    #include <aknviewappui.h>
    #include "SwitchAppUi.h"
    #include <avkon.hrh>
    #include "SwitchView.h"
    #include "SwitchContainer.h"

    class CSwitchAppUi;


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

    iListBox = new(ELeave) CAknSingleStyleListBox;
    iListBox->SetContainerWindowL( *this );
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader,R_SWITCH_LISTBOX);
    iListBox->SetListBoxObserver(this);

    iListBox->ConstructFromResourceL(reader);
    iListBox->CreateScrollBarFrameL(ETrue);
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
    CleanupStack::PopAndDestroy(); // Resource reader
    InitListBox();

    SetRect(aRect);
    ActivateL();
    }

    // Destructor
    CSwitchContainer::~CSwitchContainer()
    {
    delete iListBox;
    }

    void CSwitchContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iListBox->SetRect(Rect());
    }


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


    CCoeControl* CSwitchContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;
    default:
    return NULL;
    }
    }


    void CSwitchContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbGray);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);
    }


    int CSwitchContainer::InitListBox()
    {
    CTextListBoxModel *model= iListBox->Model();
    MDesCArray *itemList=model->ItemTextArray();
    CDesCArray *itemArray = (CDesCArray*) itemList ;
    TBuf<100> txt;
    RFs fsSession;
    RDbNamedDatabase database;
    User::LeaveIfError(fsSession.Connect());
    // _LIT(KDbFileName,"\\system\\mydb.db");
    _LIT(KDbFileName,"c:\\epoc32ex\\data\\mydata.db");


    TInt ret = database.Open(fsSession,KDbFileName);
    if(ret!=KErrNone)
    { _LIT(KMessage,"No Data");
    CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
    informationNote->ExecuteLD(KMessage);
    return 0;
    }
    //CleanupClosePushL(database);
    if (model->NumberOfItems() > 0)
    {

    }
    TBuf<100> name;
    _LIT(KSQLQuery, "SELECT * FROM emp");
    RDbView view;
    ret = view.Prepare(database, TDbQuery(KSQLQuery));
    if(ret != KErrNone)
    {
    // iEikonEnv->InfoMsg(_L("PrepareError"));
    }
    ret = view.EvaluateAll();
    if(ret != KErrNone)
    {
    // iEikonEnv->InfoMsg(_L("EvaluateError"));
    }
    view.FirstL();

    //R_AKNEXLIST_BUFFER);
    while (view.AtRow())
    {
    CEikonEnv::Static()->ReadResource(txt,R_DATABASE_DATA1);
    view.GetL();
    name = view.ColDes(2);
    //iCoeEnv->InfoMsg(name);
    txt.Append(name);
    //txt.Delete(0,2);
    itemArray->AppendL(txt);
    view.NextL();
    }
    iListBox->HandleItemAdditionL();

    view.Close();
    database.Close();
    //CleanupStack::PopAndDestroy();
    fsSession.Close();
    return 1;
    }

    void CSwitchContainer::HandleListBoxEventL(CEikListBox *aListBox, TListBoxEvent aEventType)
    {
    if(aEventType == EEventItemClicked)
    {
    AppUi()->HandleCommandL(ESwitchCmdAppView2);
    }

    }

    TKeyResponse CSwitchContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {

    if (iListBox)
    {
    iListBox->UpdateScrollBarsL();
    return iListBox->OfferKeyEventL(aKeyEvent, aType);
    }
    return EKeyWasNotConsumed;
    }
    // End of File
    **********************************************************************
    SwitchAppUi.cpp


    /*
    * ============================================================================
    * Name : CSwitchAppUi from SwitchAppUi.cpp
    * Part of : Switch
    * Created : 04/23/2003 by
    * Implementation notes:
    * Initial content was generated by Series 60 AppWizard.
    * Version :
    * Copyright:
    * ============================================================================
    */

    // INCLUDE FILES
    #include "SwitchAppUi.h"
    #include "SwitchView.h"
    #include "SwitchView2.h"
    #include <Switch.rsg>
    #include "switch.hrh"

    #include <avkon.hrh>
    #include "SwitchContainer.h"
    #include <aknnotewrappers.h>

    class SwitchContainer;


    // ================= MEMBER FUNCTIONS =======================
    //
    // ----------------------------------------------------------
    // CSwitchAppUi::ConstructL()
    // ?implementation_description
    // ----------------------------------------------------------
    //
    void CSwitchAppUi::ConstructL()
    {
    BaseConstructL();

    // Show tabs for main views from resources
    CEikStatusPane* sp = StatusPane();

    // Fetch pointer to the default navi pane control
    iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
    TUid::Uid(EEikStatusPaneUidNavi));

    // Tabgroup has been read from resource and it were pushed to the navi pane.
    // Get pointer to the navigation decorator with the ResourceDecorator() function.
    // Application owns the decorator and it has responsibility to delete the object.
    iDecoratedTabGroup = iNaviPane->ResourceDecorator();
    if (iDecoratedTabGroup)
    {
    iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
    }

    CSwitchView* view1 = new (ELeave) CSwitchView;

    CleanupStack::PushL( view1 );
    view1->ConstructL();
    AddViewL( view1 ); // transfer ownership to CAknViewAppUi
    CleanupStack::Pop(); // view1

    CSwitchView2* view2 = new (ELeave) CSwitchView2;

    CleanupStack::PushL( view2 );
    view2->ConstructL();
    AddViewL( view2 ); // transfer ownership to CAknViewAppUi
    CleanupStack::Pop(); // view2

    SetDefaultViewL(*view1);

    }


    CSwitchAppUi::~CSwitchAppUi()
    {
    delete iDecoratedTabGroup;
    }


    void CSwitchAppUi::DynInitMenuPaneL(
    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
    {
    }


    TKeyResponse CSwitchAppUi::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(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
    }
    break;
    case EKeyRightArrow:
    if( (active + 1) < count )
    {
    active++;
    iTabGroup->SetActiveTabByIndex( active );
    ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
    }
    break;
    default:
    return EKeyWasNotConsumed;
    break;
    }

    return EKeyWasConsumed;
    }


    void CSwitchAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case EEikCmdExit:
    {
    Exit();
    break;
    }
    case ESwitchCmdAppView1:
    {
    ActivateLocalViewL(TUid::Uid(ESwitchView1Tab));
    break;
    }
    case ESwitchCmdAppView2:
    {
    ActivateLocalViewL(TUid::Uid(ESwitchView2Tab));
    break;
    }
    // TODO: Add Your command handling code here

    default:
    break;
    }
    }

    // End of File

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Beijing
    Posts
    3,609
    Hi,

    I do not quite understand your question. Could you please elaborate it more? Your "CSwitchContainer" should be used inside one of your views (either CSwitchView or CSwitchView2 ). That part of code is missing (not here).

    Liuxg
    Forum Nokia

  5. #5
    Registered User
    Join Date
    May 2003
    Location
    Germany
    Posts
    40
    that's clear!
    HandleCommand is not a memeber of AppUi, what you haven't defined. I think you will use the upper class of your Appui and then it's right!

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    35

    Re: open a view by clicking the listbox item

    Hi ,

    I am configuring nokia open bluetooth source code to build my application to send other file like text over bluetooth.

    But when i compile it by saving read only file in other project.

    I got following errors:

    In open Source code it is written working on SDK 7.0s

    I am using SDk 7.0s,VC6 and Win XP

    plz ....plz....help me....

    Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(215) : error C2065: 'EEikBidSelect' : undeclared identifier
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(215) : error C2057: expected constant expression
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(570) : error C2065: 'EAknEditorUpperCase' : undeclared identifier
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(570) : error C2057: expected constant expression
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(571) : error C2065: 'EAknEditorLowerCase' : undeclared identifier
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(571) : error C2057: expected constant expression
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(573) : error C2065: 'EAknEditorTextCase' : undeclared identifier
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\avkon.hrh(573) : error C2057: expected constant expression
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknappui.h(34) : error C2143: syntax error : missing ';' before '*'
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknappui.h(34) : error C2071: 'CAknKeySoundSystem' : illegal storage class
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknappui.h(34) : error C2501: 'CAknKeySoundSystem' : missing storage-class or type specifiers
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknappui.h(34) : error C2501: 'KeySounds' : missing storage-class or type specifiers
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknview.h(116) : error C2146: syntax error : missing ';' before identifier 'iFlags'
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknview.h(116) : error C2501: 'TBitFlags' : missing storage-class or type specifiers
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknview.h(116) : error C2501: 'iFlags' : missing storage-class or type specifiers
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\AknGrid.h(165) : error C2039: 'EmptyListText' : is not a member of 'CAknGridView'
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\AknGridView.h(46) : see declaration of 'CAknGridView'
    \Symbian\7.0s\Nokia_7710_SDK\EPOC32\INCLUDE\aknlists.h(1011) : error C2504: 'CColumnListBoxView' : base class undefined
    D:\WORK\SRC\Btcomcontrolappui.cpp(9) : fatal error C1083: Cannot open include file: 'btcomcontrol.rsg': No such file or directory
    Error executing cl.exe.

    Btcomcontrolappui.obj - 18 error(s), 0 warning(s)

Posting Permissions

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