×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Question a error about listbox and a findbox

    hi
    I coding for a listbox and afindbox.
    But a error launch when my program exit.
    I debug my program, I find that do the code below, the error should launch.
    // Destructor
    CLookupContainer::~CLookupContainer()
    {

    if(iEngine)
    {
    delete iEngine;
    }

    if(iFindBox)
    delete iFindBox;

    if(iListBox)
    delete iListBox; // the error launch when step this line.


    if(iCnvCharacterSetConverter)
    {
    delete iCnvCharacterSetConverter;
    }

    }

    My codes about the main program below:
    Please see them,
    and give me some suggestion.

    Thank you very much.

    in the .h file
    I define the two object.

    private: //data

    CEikTextListBox * iListBox;

    CAknSearchField* iFindBox;

    in the .cpp file,
    the main codes about the program below;
    please see them.

    void CLookupContainer::ConstructL(const TRect& aRect)
    {
    iCnvCharacterSetConverter = CCnvCharacterSetConverter::NewL();
    //CCnvCharacterSetConverter::TAvailability avail = CCnvCharacterSetConverter::EAvailable;

    CreateWindowL();

    if ( iListBox )
    {
    delete iListBox;
    iListBox = NULL;
    }
    //iListBox = new( ELeave ) CAknSingleStyleListBox ();
    iListBox = new( ELeave ) CAknDoubleStyleListBox();

    iEngine = CExporterEngine::NewL(CEikonEnv::Static()->FsSession());
    iEngine->GetMessagesL(iCallBack);


    CAknSearchField::TSearchFieldStyle style(CAknSearchField::EFixed);
    //style = CAknSearchField::EFixed;EPopup

    if ( iListBox )
    {
    // Constructs listbox.
    iListBox->ConstructL( this, 0 );

    iListBox->Model()->SetItemTextArray( iEngine->iTextArray );
    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );

    }

    iFindBox = CreateFindBoxL(iListBox, iListBox->Model(), style);

    if ( iFindBox)
    {

    iFindBox->MakeVisible( ETrue );

    }

    SetRect(aRect);
    SizeChanged();


    ActivateL();
    }

    // Destructor
    CLookupContainer::~CLookupContainer()
    {

    if(iEngine)
    {
    delete iEngine;
    }

    if(iFindBox)
    delete iFindBox;

    if(iListBox)
    delete iListBox;





    if(iCnvCharacterSetConverter)
    {
    delete iCnvCharacterSetConverter;
    }

    }



    // ---------------------------------------------------------
    // CLookupContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CLookupContainer::SizeChanged()
    {

    if ( iListBox )
    {
    if ( iFindBox )
    {
    SizeChangedForFindBox(); // Sets rectangle of listbox with findbox.
    }
    else
    {
    iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
    }
    }
    }
    // ---------------------------------------------------------
    // CLookupContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CLookupContainer::CountComponentControls() const
    {
    return 2; // return nbr of controls inside this container
    }

    // ---------------------------------------------------------
    // CLookupContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CLookupContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;
    case 1:
    return iFindBox;
    default:
    return NULL;
    }
    }

    // ---------------------------------------------------------
    // CLookupContainer:raw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CLookupContainer:raw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbWhite);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);

    }

    // ---------------------------------------------------------
    // CLookupContainer::HandleControlEventL(
    // CCoeControl* aControl,TCoeEvent aEventType)
    // ---------------------------------------------------------
    //
    void CLookupContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

    TKeyResponse CLookupContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if ( aType != EEventKey ) // Is not key event?
    {
    return EKeyWasNotConsumed;
    }


    if ( iListBox )
    {
    if ( iFindBox )
    {
    TBool needRefresh( EFalse );
    TBool flagsOfPopup( EFalse );


    // Offers the key event to find box.


    if ( AknFind::HandleFindOfferKeyEventL( aKeyEvent, aType, this,
    iListBox, iFindBox,
    flagsOfPopup,
    needRefresh ) ==
    EKeyWasConsumed )
    {

    if ( needRefresh )
    {
    iListBox->SetCurrentItemIndex(0);
    iListBox->HandleItemAdditionL();
    SizeChanged();
    DrawNow();
    }
    return EKeyWasConsumed;
    }

    }

    return iListBox->OfferKeyEventL( aKeyEvent, aType );
    }
    else
    {
    return EKeyWasNotConsumed;
    }

    }

    // ----------------------------------------------------------------------------
    // CAknExListColumnContainer::SizeChangedForFindBox()
    // Called by framework when the view size is changed for creating listbox with
    // findbox.
    // ----------------------------------------------------------------------------
    //
    void CLookupContainer::SizeChangedForFindBox()
    {
    if ( iListBox && iFindBox )
    {

    TInt findWindowResourceId( R_AVKON_FIND_PANE );
    TInt listAreaResourceId( R_AVKON_LIST_GEN_PANE_X );
    TInt findWindowParentId( R_AVKON_MAIN_PANE_PARENT_NONE );
    TBool flagsOfPopup( EFalse ); // Flag for find popup.


    /*
    TInt findWindowResourceId( R_AVKON_POPUP_FIND_WINDOW_COVER );
    TInt listAreaResourceId( R_AVKON_LIST_GEN_PANE ); //R_AVKON_LIST_GEN_PANE
    TInt findWindowParentId( R_AVKON_MAIN_PANE_PARENT_NONE );
    TBool flagsOfPopup( EFalse ); // Flag for find popup.
    */


    AknFind::HandleFindSizeChanged(
    this, iListBox, iFindBox, flagsOfPopup, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId );

    //AknFind::HandleFindSizeChanged(this, iListBox, iFindBox);
    }
    }


    CAknSearchField* CLookupContainer::CreateFindBoxL(
    CEikListBox* aListBox,
    CTextListBoxModel* aModel,
    CAknSearchField::TSearchFieldStyle aStyle )
    {
    CAknSearchField* findbox = NULL;

    if ( aListBox && aModel )
    {
    // Gets pointer of CAknFilteredTextListBoxModel. CTextListBoxModel
    model = STATIC_CAST( CAknFilteredTextListBoxModel*, aModel );
    // Creates FindBox.
    findbox = CAknSearchField::NewL( *this,
    aStyle,
    NULL,
    20 );
    CleanupStack::PushL(findbox);
    // Creates CAknListBoxFilterItems class.
    model->CreateFilterL( aListBox, findbox );
    //Filter can get by model->Filter();
    CleanupStack::Pop(findbox); // findbox
    }

    return findbox;
    }

  2. #2
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    I have search the sdk help the function HandleFindSizeChanged,
    it donot explain the function's arg.
    just like
    flagsOfPopup, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId
    Please tell me what to do about the codes below:
    AknFind::HandleFindSizeChanged(
    this, iListBox, iFindBox, flagsOfPopup, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId );

  3. #3
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    did everyone know it ?

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

    Re: a error about listbox and a findbox

    hi,

    try this

    void CMyContainer::SizeChangedForFindBox()
    {
    if ( iListBox && iFindBox )
    {

    TInt findWindowResourceId( R_AVKON_POPUP_FIND_WINDOW );
    TInt listAreaResourceId( R_AVKON_LIST_GEN_PANE );
    TInt findWindowParentId( R_AVKON_MAIN_PANE_WITH_STATUS_PANE );

    AknFind::HandleFindSizeChanged(
    this, iListBox, iFindBox, ETrue, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId );


    }
    }


    Regards,

    Mateen Maldar

  5. #5
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    Dear Mateen Maldar
    Thank you very much.
    I test your codes, the error is not launched when delete ifindbox in ~CLookupContainer().
    But the ifindbox can not show at the CLookupContainer.

    Why it is not shown?

    Maybe change some other arg,

    Please tell me,


    Thank you very much.

    your bill qu

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

    Re: a error about listbox and a findbox

    hi,

    May i know in which paltform of symbian ur working in? and plz detail me exactly wht is happening in ur code.. i Didn't got much info from ur post..

    Regards,
    Mateen Maldar

  7. #7
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    dear Mateen Maldar
    There are the .h file's codes as below


    #ifndef LOOKUPCONTAINER_H
    #define LOOKUPCONTAINER_H

    // INCLUDES
    #include <coecntrl.h>
    #include <eiktxlbx.h>
    #include <eiklbi.h>
    #include <eiklbv.h>
    #include <eiktxlbm.h>
    #include <eiktxlbx.h>
    #include <aknsfld.h>
    #include <aknutils.h>
    #include <aknlists.h>
    #include <badesca.h>
    #include <cntdb.h>
    #include <cntfield.h>
    #include <cntitem.h>
    #include <cntfldst.h>


    #include <akntabgrp.h>

    #include <charconv.h> // charconv.lib

    #include "exporter.h"

    //#include <aknexlist.rsg>
    //#include <aknexlist.mbg>

    // CLASS DECLARATION

    /**
    * CLookupContainer container control class.
    *
    */
    class CLookupContainer : public CCoeControl, MCoeControlObserver
    {
    public: // Constructors and destructor

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


    TKeyResponse OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType );

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

    public: // New functions

    public: // Functions from base classes
    TPtrC GetCurItem();
    CAknFilteredTextListBoxModel* model;
    private: // Functions from base classes

    CAknSearchField* CreateFindBoxL(CEikListBox* aListBox,CTextListBoxModel* aModel,CAknSearchField::TSearchFieldStyle aStyle );

    /**
    * From CoeControl,SizeChanged.
    */
    void SizeChanged();
    void SizeChangedForFindBox();

    /**
    * From CoeControl,CountComponentControls.
    */
    TInt CountComponentControls() const;

    /**
    * From CCoeControl,ComponentControl.
    */
    CCoeControl* ComponentControl(TInt aIndex) const;

    /**
    * From CCoeControl,Draw.
    */
    void Draw(const TRect& aRect) const;

    /**
    * From ?base_class ?member_description
    */
    // event handling section
    // e.g Listbox events
    void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);


    private: //data

    CEikTextListBox * iListBox;
    //CEikListBox CEikTextListBox CEikFormattedCellListBox

    CAknSearchField* iFindBox;

    CExporterEngine* iEngine;

    TCallBack iCallBack;

    // for encoding the text file
    CCnvCharacterSetConverter* iCnvCharacterSetConverter;

    };

    #endif

    // End of File

  8. #8
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    There are the .cpp codes as below:

    // INCLUDE FILES
    #include "LookupContainer.h"
    #include <eiklabel.h> // for example label control
    #include <f32file.h>
    #include <s32file.h>
    #include <libc\sys\unistd.h>
    #include <charconv.h>

    CAknSearchField* CLookupContainer::CreateFindBoxL(
    CEikListBox* aListBox,
    CTextListBoxModel* aModel,
    CAknSearchField::TSearchFieldStyle aStyle )
    {
    CAknSearchField* findbox = NULL;

    if ( aListBox && aModel )
    {
    // Gets pointer of CAknFilteredTextListBoxModel. CTextListBoxModel
    model = STATIC_CAST( CAknFilteredTextListBoxModel*, aModel );
    // Creates FindBox.
    findbox = CAknSearchField::NewL( *this,
    aStyle,
    NULL,
    20 );
    CleanupStack::PushL(findbox);
    // Creates CAknListBoxFilterItems class.
    model->CreateFilterL( aListBox, findbox );
    //Filter can get by model->Filter();
    CleanupStack::Pop(findbox); // findbox
    }

    return findbox;
    }


    TPtrC CLookupContainer::GetCurItem()
    {

    CAknListBoxFilterItems *pFilterItems = model->Filter();

    TInt tiTureCurIndex;
    TInt tiCurIndex;
    tiCurIndex = iListBox->CurrentItemIndex();
    tiTureCurIndex = pFilterItems->FilteredItemIndex(tiCurIndex);


    CTextListBoxModel* pModel = iListBox->Model();



    CDesCArrayFlat *pText = (CDesCArrayFlat*)pModel->ItemTextArray();
    TInt nCurSel = iListBox->CurrentItemIndex();
    if(nCurSel != -1)
    {
    TPtrC aContent = pText->MdcaPoint(tiTureCurIndex);
    return aContent;
    }
    else
    {
    _LIT(KText1,"No data ");
    TPtrC aContent1(KText1);
    return aContent1;
    }

    }

    void CLookupContainer::ConstructL(const TRect& aRect)
    {
    iCnvCharacterSetConverter = CCnvCharacterSetConverter::NewL();
    //CCnvCharacterSetConverter::TAvailability avail = CCnvCharacterSetConverter::EAvailable;

    CreateWindowL();

    if ( iListBox )
    {
    delete iListBox;
    iListBox = NULL;
    }
    //iListBox = new( ELeave ) CAknSingleStyleListBox ();
    iListBox = new( ELeave ) CAknDoubleStyleListBox();

    iEngine = CExporterEngine::NewL(CEikonEnv::Static()->FsSession());
    iEngine->GetMessagesL(iCallBack);


    CAknSearchField::TSearchFieldStyle style(CAknSearchField::ESearch);
    //style = CAknSearchField::EFixed;EPopup ESearch

    if ( iListBox )
    {
    // Constructs listbox.
    iListBox->ConstructL( this, 0 );

    iListBox->Model()->SetItemTextArray( iEngine->iTextArray );
    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );

    }

    iFindBox = CreateFindBoxL(iListBox, iListBox->Model(), style);

    if ( iFindBox)
    {

    iFindBox->MakeVisible( ETrue );

    }

    SetRect(aRect);
    SizeChanged();


    ActivateL();
    }

    // Destructor
    CLookupContainer::~CLookupContainer()
    {

    if(iEngine)
    {
    delete iEngine;
    }

    if(iFindBox)
    delete iFindBox;

    if(iListBox)
    delete iListBox;

    if(iCnvCharacterSetConverter)
    {
    delete iCnvCharacterSetConverter;
    }

    }

    // ---------------------------------------------------------
    // CLookupContainer::SizeChanged()
    // Called by framework when the view size is changed
    // ---------------------------------------------------------
    //
    void CLookupContainer::SizeChanged()
    {

    if ( iListBox )
    {
    if ( iFindBox )
    {
    SizeChangedForFindBox(); // Sets rectangle of listbox with findbox.
    }
    else
    {
    iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
    }
    }
    }
    // ---------------------------------------------------------
    // CLookupContainer::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CLookupContainer::CountComponentControls() const
    {
    return 2; // return nbr of controls inside this container
    }

    // ---------------------------------------------------------
    // CLookupContainer::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CLookupContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
    {
    case 0:
    return iListBox;
    case 1:
    return iFindBox;
    default:
    return NULL;
    }
    }

    void CLookupContainer:raw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbWhite);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.DrawRect(aRect);

    }

    void CLookupContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }



    TKeyResponse CLookupContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if ( aType != EEventKey ) // Is not key event?
    {
    return EKeyWasNotConsumed;
    }
    if ( iListBox )
    {
    if ( iFindBox )
    {
    TBool needRefresh( EFalse );
    TBool flagsOfPopup( EFalse );


    // Offers the key event to find box.


    if ( AknFind::HandleFindOfferKeyEventL( aKeyEvent, aType, this,
    iListBox, iFindBox,
    flagsOfPopup,
    needRefresh ) ==
    EKeyWasConsumed )
    {

    if ( needRefresh )
    {
    iListBox->SetCurrentItemIndex(0);
    iListBox->HandleItemAdditionL();
    SizeChanged();
    DrawNow();
    }
    return EKeyWasConsumed;
    }

    }

    return iListBox->OfferKeyEventL( aKeyEvent, aType );
    }
    else
    {
    return EKeyWasNotConsumed;
    }

    }

    // ----------------------------------------------------------------------------
    // CAknExListColumnContainer::SizeChangedForFindBox()
    // Called by framework when the view size is changed for creating listbox with
    // findbox.
    // ----------------------------------------------------------------------------
    //
    void CLookupContainer::SizeChangedForFindBox()
    {
    if ( iListBox && iFindBox )
    {
    TInt findWindowResourceId( R_AVKON_POPUP_FIND_WINDOW );
    TInt listAreaResourceId( R_AVKON_LIST_GEN_PANE );
    TInt findWindowParentId( R_AVKON_MAIN_PANE_WITH_STATUS_PANE );


    AknFind::HandleFindSizeChanged(
    this, iListBox, iFindBox, ETrue, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId );

    }
    }

    // End of File

  9. #9
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    if I change the CLookupContainer::SizeChangedForFindBox()
    change AknFind::HandleFindSizeChanged's arg
    ETrue to EFalse
    the codes as below:
    void CLookupContainer::SizeChangedForFindBox()
    {
    if ( iListBox && iFindBox )
    {
    TInt findWindowResourceId( R_AVKON_POPUP_FIND_WINDOW );
    TInt listAreaResourceId( R_AVKON_LIST_GEN_PANE );
    TInt findWindowParentId( R_AVKON_MAIN_PANE_WITH_STATUS_PANE );


    AknFind::HandleFindSizeChanged(
    this, iListBox, iFindBox, EFalse, findWindowResourceId,
    listAreaResourceId, R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
    findWindowParentId );

    }
    }



    The ifindbox can be shown,

    but the error launch at delete ifindbox at ::~CLookupContainer()

    why?

    Please tell me.

    Thank you very much.

    !!!

  10. #10
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    my sdk is s60 2nd edition sdk fp2.

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

    Re: a error about listbox and a findbox

    hi,

    try this in ur ConstructL

    CAknSearchField::TSearchFieldStyle style(CAknSearchField::ESearch );
    style = CAknSearchField::EPopup;

    Regards,
    Mateen Maldar

  12. #12
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    hi mateen
    if style = CAknSearchField::EPopup;
    the program can not error when disconstructl.
    But the ifindbox is number only when I click key,
    I hope the ifindbox is text, not only number.
    How to change it?

    Thank you very much.

  13. #13
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    I have seen a sample at symbian website, which name is lookup.
    http://www.symbian.com/developer/tec...ps/lookup.html
    The Lookup application populates a CEikFormattedCellListBox that displays the entries matching the telephone number entered by the user.
    I hope my listbox can matching text, not only number.
    So I change CEikFormattedCellListBox to CEikTextListBox
    and change CAknSearchField::EPopup to ESearch.

    But error which launch I have said.

    How should I change the lookup program for listbox can enter text?

    Thank you very much.

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

    Re: a error about listbox and a findbox

    hi,

    use
    SetFocus(ETrue);

    In the constructL for the findbox

    which will take both alphabets and numeric.

    sorry i'm in my native place for a week hoilday. sorry for the delay

    regards,
    Mateen Maldar

  15. #15
    Regular Contributor
    Join Date
    Jul 2004
    Posts
    201

    Re: a error about listbox and a findbox

    Dear mateen
    Thank for your suggestion.
    I will try it.
    I am very exciting.
    I feel that it can solve the problem.
    Thank you very much.

Similar Threads

  1. Findbox with graphic listbox problem (wrong filtering)
    By yavolinsky in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-02-03, 02:32
  2. Replies: 2
    Last Post: 2007-04-05, 06:22
  3. Deleting an open FindBox crashes app
    By inc0gn1t007 in forum Symbian
    Replies: 4
    Last Post: 2006-11-03, 13:38
  4. How to modify listbox items in a findbox view?
    By inc0gn1t007 in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-05-03, 17:53
  5. how to use listbox with findbox
    By billqu in forum Symbian
    Replies: 2
    Last Post: 2005-01-10, 03:45

Posting Permissions

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