×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    35

    CAknForm derived class does not display via navi pane

    Dear All,

    Can anybody tell me why my CAknForm derived class does not display when the view is activated through the navi pane, but is displayed fine when I set it as the default view?

    In my ConstructL in my CAknViewAppUi derived class I have -

    ------------------------------------------------------------
    void CABCEditorAppUi::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();
    }

    CABCEditorView* view1 = new (ELeave) CABCEditorView;

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

    CABCEditorView2* view2 = new (ELeave) CABCEditorView2;

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

    CABCEditorViewProfile* viewProfile = new (ELeave) CABCEditorViewProfile;

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

    SetDefaultViewL(*view1);
    //SetDefaultViewL(*viewProfile); // viewProfile is displayed if I do this
    // but not when view select by navi pane

    }
    ------------------------------------------------------------

    In the same class my HandleKeyEventL method moves between views using the navi pane using standard code taken from the examples.

    When I run the application and use right arrow to get to select the view called 'viewProfile' I get a blank grey window, when I should get a Form displayed.

    I *know* my form works because I can do setDefaultViewL(*viewProfile) and my form
    is displayed... is just doesn't get display when done through the navi pane.

    The View class, Container class and CAknForm derived class are shown below.

    Any help would be very much appreciated.

    Thanks,

    Andy.



    /*
    * ============================================================================
    * Name : CABCEditorView from ABCEditorView.h
    * Part of : ABCEditor
    * Created : 13/02/2003 by
    * Implementation notes:
    * Initial content was generated by Series 60 AppWizard.
    * Version :
    * Copyright:
    * ============================================================================
    */

    // INCLUDE FILES
    #include <aknviewappui.h>
    #include <avkon.hrh>
    #include <ABCEditor.rsg>
    #include "ABCEditorViewProfile.h"
    #include "ABCEditorContainerProfile.h"

    #include <abceditor.rsg>

    #include <eikspane.h>
    #include <aknnavi.h>

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

    // ---------------------------------------------------------
    // CABCEditorView::ConstructL(const TRect& aRect)
    // EPOC two-phased constructor
    // ---------------------------------------------------------
    //
    void CABCEditorViewProfile::ConstructL()
    {
    BaseConstructL( R_ABCEDITOR_VIEW_PROFILE );

    }

    // ---------------------------------------------------------
    // CABCEditorView::~CABCEditorView()
    // ?implementation_description
    // ---------------------------------------------------------
    //
    CABCEditorViewProfile::~CABCEditorViewProfile()
    {
    if ( iContainer )
    {
    AppUi()->RemoveFromViewStack( *this, iContainer );
    }
    delete iContainer;
    }

    // ---------------------------------------------------------
    // TUid CABCEditorView::Id()
    // ?implementation_description
    // ---------------------------------------------------------
    //
    TUid CABCEditorViewProfile::Id() const
    {
    return KViewProfileId;
    }

    // ---------------------------------------------------------
    // CABCEditorView::HandleCommandL(TInt aCommand)
    // ?implementation_description
    // ---------------------------------------------------------
    //
    void CABCEditorViewProfile::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {
    case EAknSoftkeyOk:
    {
    iEikonEnv->InfoMsg( _L("view1 ok") );
    break;
    }
    case EAknSoftkeyBack:
    {
    AppUi()->HandleCommandL(EEikCmdExit);
    break;
    }
    default:
    {
    AppUi()->HandleCommandL( aCommand );
    break;
    }
    }
    }

    // ---------------------------------------------------------
    // CABCEditorView::HandleClientRectChange()
    // ---------------------------------------------------------
    //
    void CABCEditorViewProfile::HandleClientRectChange()
    {
    if ( iContainer )
    {
    iContainer->SetRect( ClientRect() );
    }
    }

    // ---------------------------------------------------------
    // CABCEditorView::DoActivateL(...)
    // ?implementation_description
    // ---------------------------------------------------------
    //
    void CABCEditorViewProfile::DoActivateL(
    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
    const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
    {
    iContainer = new (ELeave) CABCEditorContainerProfile;
    // what is Message Object Provider ?
    iContainer->SetMopParent(this);
    iContainer->ConstructL( ClientRect() );
    // Add container to this view's control stack
    AppUi()->AddToStackL( *this, iContainer );

    iContainer->DisplayFormL();

    /*
    // Get status pane (in order to get navi pane)
    CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
    iNaviPane =
    (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
    // Set default navi pane
    iNaviPane->PushDefaultL ();
    */

    }
    }

    // ---------------------------------------------------------
    // CABCEditorView::HandleCommandL(TInt aCommand)
    // ?implementation_description
    // ---------------------------------------------------------
    //
    void CABCEditorViewProfile::DoDeactivate()
    {
    if ( iContainer )
    {
    AppUi()->RemoveFromViewStack( *this, iContainer );
    //iNaviPane->Pop(); // Set navi pane back
    }

    delete iContainer;
    iContainer = NULL;
    }

    // End of File




    /*
    * ============================================================================
    * Name : CABCEditorContainerProfile from ABCEditorContainer.h
    * Part of : ABCEditor
    * Created : 13/02/2003 by
    * Implementation notes:
    * Initial content was generated by Series 60 AppWizard.
    * Version :
    * Copyright:
    * ============================================================================
    */

    // INCLUDE FILES
    #include "ABCEditorContainerProfile.h"

    #include <eiklabel.h> // for example label control
    #include "abceditorformprofile.h"
    #include <abceditor.rsg>

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

    // ---------------------------------------------------------
    // CABCEditorContainerProfile::ConstructL(const TRect& aRect)
    // EPOC two phased constructor
    // ---------------------------------------------------------
    //
    void CABCEditorContainerProfile::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    SetRect(aRect);
    ActivateL();
    }

    void CABCEditorContainerProfile::DisplayFormL()
    {
    CABCEditorFormProfile* form = CABCEditorFormProfile::NewL();
    form->ExecuteLD(R_AKNEXFORM_NONE_FIELD_DIALOG);
    DrawNow();
    }

    // Destructor
    CABCEditorContainerProfile::~CABCEditorContainerProfile()
    {
    }

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

    // ---------------------------------------------------------
    // CABCEditorContainerProfile::CountComponentControls() const
    // ---------------------------------------------------------
    //
    TInt CABCEditorContainerProfile::CountComponentControls() const
    {
    return 0; // return nbr of controls inside this container
    }

    // ---------------------------------------------------------
    // CABCEditorContainerProfile::ComponentControl(TInt aIndex) const
    // ---------------------------------------------------------
    //
    CCoeControl* CABCEditorContainerProfile::ComponentControl(TInt aIndex) const
    {
    return NULL;
    }

    // ---------------------------------------------------------
    // CABCEditorContainerProfile::Draw(const TRect& aRect) const
    // ---------------------------------------------------------
    //
    void CABCEditorContainerProfile::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);
    }

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

    // End of File

    /*
    * ============================================================================
    * Name : CABCEditorFormProfile.h
    * Part of : AknExForm
    * Copyright (c) 2000 Nokia Mobile Phones. All rights reserved.
    * ============================================================================
    */

    // INCLUDE FILES
    #include <eikcapc.h>
    //#include <eikseced.h> // for secret editor
    //#include <aknslider.h> // for slider

    #include "abceditorformprofile.h"
    #include <abceditor.rsg>




    // FUNCTION PROTOTYPES

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

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::NewL()
    // Two-phased constructor.
    // ----------------------------------------------------------------------------
    //
    CABCEditorFormProfile* CABCEditorFormProfile::NewL()
    {
    CABCEditorFormProfile* self = new (ELeave) CABCEditorFormProfile();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::~CABCEditorFormProfile()
    // Destructor.
    // ----------------------------------------------------------------------------
    //
    CABCEditorFormProfile::~CABCEditorFormProfile()
    {
    }


    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::CABCEditorFormProfile()
    // Default constructor.
    // ----------------------------------------------------------------------------
    //
    CABCEditorFormProfile::CABCEditorFormProfile()
    {
    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::ConstructL()
    // Second-phase constructor.
    // ----------------------------------------------------------------------------
    //
    void CABCEditorFormProfile::ConstructL()
    {
    CAknForm::ConstructL();
    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::ExecuteLD( TInt aResourceId )
    //
    // ----------------------------------------------------------------------------
    //
    /*
    TInt CABCEditorFormProfile::ExecuteLD( TInt aResourceId )
    {
    return CAknForm::ExecuteLD( aResourceId );
    }
    */

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::PrepareLC( TInt aResourceId )
    //
    // ----------------------------------------------------------------------------
    //
    //void CABCEditorFormProfile::PrepareLC( TInt aResourceId )
    //{


    // CAknForm::PrepareLC( R_AKNEXFORM_NONE_FIELD_DIALOG );
    //}

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::SaveFormDataL()
    // Save form data.
    // ----------------------------------------------------------------------------
    //
    TBool CABCEditorFormProfile::SaveFormDataL()
    {

    if (ControlOrNull(EAknExFormDlgCtrlIdEdwin01))
    {
    GetEdwinText(iEdwinData1, EAknExFormDlgCtrlIdEdwin01);
    TPtrC edwinLabel = Line(EAknExFormDlgCtrlIdEdwin01)->GetFullCaptionText();
    iEdwinLabel1 = edwinLabel;
    }

    return ETrue;
    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::DoNotSaveFormDataL()
    // Does not save form data.
    // ----------------------------------------------------------------------------
    //
    void CABCEditorFormProfile::DoNotSaveFormDataL()
    {

    if (ControlOrNull(EAknExFormDlgCtrlIdEdwin01))
    {
    SetEdwinTextL(EAknExFormDlgCtrlIdEdwin01, &iEdwinData1);
    Line(EAknExFormDlgCtrlIdEdwin01)->SetCaptionL(iEdwinLabel1);
    Line(EAknExFormDlgCtrlIdEdwin01)->iCaption->CropText();
    }

    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::PostLayoutDynInitL()
    // Set default field value to member data.
    // ----------------------------------------------------------------------------
    //
    void CABCEditorFormProfile::PostLayoutDynInitL()
    {
    CAknForm::PostLayoutDynInitL();
    SaveFormDataL();
    }

    // ----------------------------------------------------------------------------
    // CABCEditorFormProfile::QuerySaveChangesL()
    // Show save query. If user answers "No" to this query.
    // return field value to the value which is before editing.
    // This is called Back-softkey when edit mode.
    // ----------------------------------------------------------------------------
    //
    TBool CABCEditorFormProfile::QuerySaveChangesL()
    {
    TBool isAnsYes(CAknForm::QuerySaveChangesL());

    if (isAnsYes)
    {
    SaveFormDataL();
    }
    else
    {
    // Case that answer "No" to query.
    DoNotSaveFormDataL();
    }

    return isAnsYes;
    }

    // End of File

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    35

    RE: CAknForm derived class does not display via navi pane

    I found the problem. You cannot call ExecuteLD on a CAknForm derived class from within your view's DoActivateL method. You must instantiate the class in your view's DoActivateL method, and then call myform->ExecuteLD from within your view's HandleCommand (or OfferKeyEvent?)

    I presume that calling ExecuteLD in DoActivateL is pointless because the ready to draw flag on the view is not set until this method returns, hence the blank screen.

    I hope this is of use to somebody !

    Andy.

Posting Permissions

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