×

Discussion Board

Results 1 to 15 of 15
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61

    Menu in Form fails to show up...

    Hi all,

    Have a bit of problem, and I hope someone can help me.

    I've implemented a Form (CAknForm) and I wan't to supress the
    original menu (Edit, Save etc) and add my own. Following the
    SDK and various posts in this forum I thought I had it figured
    out but alas, I was wrong :)

    Here's what I do: I call CAknForm's ConstructL with my new menu
    resource id in the NewL of my class, I supress the default menu
    in DynInitMenuPanel using SetItemDimmed.
    I thought that was all I had to do but the only result I get is
    that no menu is shown when I press the Options button.
    Am I missing something here? (well obviously, but what? :)

    Cheers,
    Bjorn

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

    Use the following code:

    void CDBMSexampleForm::DynInitMenuPaneL( TInt aResourceId,
    CEikMenuPane* aMenuPane )
    {

    TBuf<64> des;

    CAknForm::DynInitMenuPaneL( aResourceId, aMenuPane );
    if ( aResourceId == R_AVKON_FORM_MENUPANE )
    {
    CEikonEnv::Static()->ReadResource( des, R_ADD_RECORD1 );
    AddMenuItem( des, EDBMSexampleCmdSaveRecord, aMenuPane);

    // Disable unnecessary menu items when "Edit" is selected
    aMenuPane->SetItemDimmed( EAknFormCmdAdd, ETrue );
    aMenuPane->SetItemDimmed( EAknFormCmdDelete, ETrue );
    aMenuPane->SetItemDimmed( EAknFormCmdLabel, ETrue );
    }
    }

    void CDBMSexampleForm::AddMenuItem(const TDesC &aDesC, TInt aCommandId, CEikMenuPane* aMenuPane)
    {
    CEikMenuPaneItem::SData itemData;
    itemData.iText = aDesC;
    itemData.iCommandId = aCommandId;
    itemData.iFlags = 0;
    itemData.iCascadeId = 0;
    aMenuPane->AddMenuItemL( itemData );
    }

    Liuxg
    Forum Nokia

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Switzerland
    Posts
    61
    thanks! I'll try that.

    Regards,
    Bjorn

  4. #4
    Regular Contributor
    Join Date
    Mar 2006
    Location
    India
    Posts
    138

    Re: Menu in Form fails to show up...

    Hi,
    I am starting to implement the default CAknForm ,
    now all the fields are displaying but option menu is not showing up.
    PLz help.
    thnks
    Anand

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Menu in Form fails to show up...

    Quote Originally Posted by anand_zain76
    I am starting to implement the default CAknForm ,
    now all the fields are displaying but option menu is not showing up.
    Check "form" example of the SDK. Have you specified the "buttons" field and EEikDialogFlagCbaButtons flag in your dialog resource?

  6. #6
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    Hi,
    I am facing the same problem,though I have added buttons and set flags.Still my menu in dialog doesn't open.
    I followed exactly your code in my dialog class for DyninitMenuPaneL.And in HandleCommand:
    switch ( aCommand )
    {
    case EAknSoftkeyBack:
    case EAknSoftkeyExit:

    case ERegistrationReset:
    case ERegistrationCmdAppRegister:


    //TBool OkToExit( TInt aButtonId);
    //case ERegistrationReset:
    break;
    default:
    break;
    }
    Function OkToExit() contains code for 3 of the cases containing different information notes.
    Plz Favour to overcome!
    Regards,
    Sohni.
    Last edited by sohnisheth; 2006-08-15 at 07:50.

  7. #7
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Menu in Form fails to show up...

    Hi,

    I use this code.. and it's working..

    Code:
    void CSMSExampleHandshakeForm::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
            {
            CAknForm::DynInitMenuPaneL(aResourceId,aMenuPane);
    
            if (aResourceId == R_AVKON_FORM_MENUPANE)
               {
                    // Disable default menu items in form
                    aMenuPane->SetItemDimmed(EAknFormCmdLabel, ETrue);
                    aMenuPane->SetItemDimmed(EAknFormCmdAdd, ETrue);
                    aMenuPane->SetItemDimmed(EAknFormCmdDelete, ETrue);
                    aMenuPane->SetItemDimmed(EAknFormCmdSave, ETrue);
    
                    // Add new menu items in form
                    aMenuPane->AddMenuItemsL( R_HANDSHAKE_MENU, 0, ETrue);
               }
            }
    
    // Function to handle new menu items in form
    void CSMSExampleHandshakeForm::ProcessCommandL(TInt aCommandId)
    {
      switch(aCommandId)
      {
        case ESMSExampleCmdAddHandshake:
          {
           break;
          }
    
        default:
          break;
      }
    CAknForm::ProcessCommandL(aCommandId);
    }

    In resource file:
    Code:
    // Handshake Form menu options
    RESOURCE MENU_PANE r_handshake_menu
            {
            items =
                    {
                    MENU_ITEM
                            {
                            command = ESMSExampleCmdAddHandshake;
                            txt = SELECT_HANDSHAKE_TEXT;
                            },
                    MENU_ITEM
                            {
                            command = ESMSExampleCmdSendHandshake;
                            txt = SEND_HANDSHAKE_TEXT;
                            }
                    };
            }

    Gud luck!

  8. #8
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    Thanks ninidotnet,
    Still there is no change!Is there any change that I have forgotten to make?
    Regards,
    Sohni.

  9. #9
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    hi all,
    Still clicking Option Menu nothing happens.Even that doesn't show menu.While if I putCAknForm::ConstructL(); in my constructL() I get default menu of form.But my own menu is not opening?
    Please help!
    Sohni.

  10. #10
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    Hi all,
    still I am stuck with the problem if anybuddy can get me a clue?
    I want my customized menu in dialog of edwins in form.
    But when I tried like IstelCallApp in example in sdk.I just come out of dialog.and menu doesn't appear.

    Regards,
    Sohni.
    Last edited by sohnisheth; 2006-08-23 at 13:39.

  11. #11
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Menu in Form fails to show up...

    Hi,

    Maybe you can send here the code in resource file?

  12. #12
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    Thanks ninidotnet,

    My rss file:
    RESOURCE RSS_SIGNATURE { }
    RESOURCE TBUF r_default_document_name { buf="hi"; }
    RESOURCE EIK_APP_INFO
    {
    cba = R_AVKON_SOFTKEYS_OK_CANCEL;
    }
    RESOURCE AVKON_VIEW r_formapp_view
    { }
    RESOURCE TBUF r_formapp_text_label_title
    {
    buf = qtn_formapp_label_title;
    }
    RESOURCE DIALOG r_formapp_navipane_dialog
    {
    flags = EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect |
    EEikDialogFlagNoTitleBar | EEikDialogFlagNoBorder |
    EEikDialogFlagCbaButtons;

    buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
    pages = r_formapp_navipane_pages;
    }
    RESOURCE ARRAY r_formapp_navipane_pages
    {
    items =
    {
    PAGE
    {
    id = EformappPageCtrlIdPagePhone1;
    text = STRING_formapp_status_pane_page_phone1;
    form = r_phone1_form;
    }
    };
    }
    RESOURCE FORM r_phone1_form
    {
    flags = EEikFormEditModeOnly | EEikFormUseDoubleSpacedFormat;
    items =
    {
    DLG_LINE
    {
    type = EEikCtEdwin;
    prompt = STRING_formapp_form_label_phone1;
    id = EformappDlgCtrlIdPhone1;
    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
    control = EDWIN
    {
    flags = EEikEdwinNoHorizScrolling;
    allowed_input_modes=EAknEditorTextInputMode;
    default_input_mode=EAknEditorTextInputMode;
    width = FORMAPP_EDWIN_WIDTH;
    lines = FORMAPP_EDWIN_LINES;
    maxlength = EformappEdwinMaxLength;
    max_view_height_in_lines = 5;
    base_line_delta = 21;
    };},
    DLG_LINE
    {
    type = EEikCtEdwin;
    prompt = STRING_formapp_form_label_address;
    id = EformappDlgCtrlIdAddress;
    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
    control = EDWIN
    {
    flags = EEikEdwinNoHorizScrolling | EEikFormUseDoubleSpacedFormat;
    allowed_input_modes=EAknEditorTextInputMode;
    default_input_mode=EAknEditorTextInputMode;
    width = 3;
    lines = 3;
    maxlength = EformappEdwinMaxLength;
    max_view_height_in_lines = 10;
    base_line_delta = 21;
    };},
    DLG_LINE
    {
    type = EEikCtEdwin;
    prompt = STRING_formapp_form_label_Email;
    id = EformappDlgCtrlIdEmail;
    itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys;
    control = EDWIN
    {
    flags = EEikEdwinNoHorizScrolling;
    allowed_input_modes=EAknEditorTextInputMode;
    default_input_mode=EAknEditorTextInputMode;
    width = FORMAPP_EDWIN_WIDTH;
    lines = FORMAPP_EDWIN_LINES;
    special_character_table = R_AVKON_EMAIL_ADDR_SPECIAL_CHARACTER_TABLE_DIALOG;
    default_case = EAknEditorLowerCase;
    maxlength = EformappEdwinMaxLength;
    max_view_height_in_lines = 5;
    base_line_delta = 21;
    };} };
    }
    RESOURCE MENU_PANE r_phone_menu_pane
    {
    items=
    {
    MENU_ITEM
    {
    command = ERegistrationCmdAppRegister;
    txt = "Register";
    },
    MENU_ITEM
    {
    command = ERegistrationReset;
    txt = "Reset";
    },
    MENU_ITEM
    {
    command = EAknCmdExit;
    txt = "Back";
    }};}
    RESOURCE TBUF32 r_hewb_command1_text { buf="Hello"; }
    RESOURCE TBUF40 r_registration_err_text
    {buf = "Emailid is not Valid!";}
    RESOURCE TBUF40 r_registration_info_text
    {buf = "Registration Succeded!";}
    My formappDialog file:
    CformappDialog* CformappDialog::NewL()
    {
    CformappDialog* self =
    new (ELeave) CformappDialog();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }
    TInt CformappDialog::ExecuteLD( TInt aResourceId )
    {TInt retCode;
    retCode = CAknForm::ExecuteLD( aResourceId );
    TryChangeFocusToL(EformappDlgCtrlIdPhone1);
    return( retCode );
    }
    TKeyResponse CformappDialog::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if (aType == EEventKey)
    {
    switch (aKeyEvent.iCode)
    {case EKeyYes:
    {
    TInt focusControlId = IdOfFocusControl();
    switch (focusControlId)
    {
    case EformappDlgCtrlIdPhone1:
    {
    ProcessCommandL(ERegistrationCmdAppRegister);
    return EKeyWasConsumed;
    }
    default:
    break;
    }
    }
    break;
    case EKeyNo:
    break;
    return EKeyWasConsumed;
    }
    }
    return CAknForm::OfferKeyEventL(aKeyEvent, aType);
    }
    CformappDialog::~CformappDialog()
    { }
    TBool CformappDialog::ValidateInput()
    {
    //Email validation code.
    ....
    return isValid;
    }
    void CformappDialog::ProcessCommandL( TInt aCommandId )
    {
    switch (aCommandId)
    {

    case ERegistrationCmdAppRegister:
    {
    TInt afocusControlId = IdOfFocusControl();
    void performRegister();
    }
    break;
    case ERegistrationReset:
    //function();
    break;
    default:

    CAknForm::ProcessCommandL(aCommandId);
    break;
    }
    }
    void CformappDialog::SetDlgPage(TInt aPageId)
    {
    iPageId = aPageId;
    }

    void CformappDialog::SetTitlePane(CAknTitlePane* aTitlePane)
    {
    iTitlePane = aTitlePane;
    }

    void CformappDialog::SetContainer(CformappContainer* aContainer)
    {
    iContainer = aContainer;
    }

    CformappDialog::CformappDialog()
    {
    }
    void CformappDialog::performRegister()
    {

    if ( ValidateInput())
    {
    iCoeEnv->ReadResourceL( iNote, R_REGISTRATION_INFO_TEXT );
    CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote;
    dlg->ExecuteLD(iNote);
    }
    else
    {
    iCoeEnv->ReadResourceL( iNote, R_REGISTRATION_ERR_TEXT );
    CAknErrorNote* dlg = new ( ELeave ) CAknErrorNote;
    dlg->ExecuteLD( iNote );
    TryChangeFocusToL(EformappDlgCtrlIdEmail);

    }

    }
    void CformappDialog::ConstructL()
    {
    iTitlePane = NULL;
    CAknForm::ConstructL();
    CAknDialog::ConstructL(R_PHONE_MENU_PANE);

    }

    void CformappDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
    {
    TInt pageId = ActivePageId();
    TInt focusControlId = IdOfFocusControl();

    if (aResourceId == R_PHONE_MENU_PANE)
    {
    switch (pageId)
    {
    case EformappPageCtrlIdPagePhone1:
    {
    //Phone Menu
    switch (focusControlId)
    {
    case EformappDlgCtrlIdPhone1:
    {
    aMenuPane->AddMenuItemsL(R_PHONE_MENU_PANE,0,1);
    aMenuPane->SetItemDimmed(EAknFormCmdAdd,TRUE);
    aMenuPane->SetItemDimmed(EAknFormCmdLabel,TRUE);
    aMenuPane->SetItemDimmed(EAknFormCmdDelete,TRUE);
    break;
    }
    default:
    break;
    }}}}
    else
    {
    CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);
    }

    void CformappDialog::PostLayoutDynInitL()
    {
    //Call the base class routine
    CAknForm::PostLayoutDynInitL();
    }
    Sohni.

  13. #13
    Regular Contributor
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    246

    Re: Menu in Form fails to show up...

    Hi,

    I'm not sure about this but maybe you can try to remove ConstructL() from your CformappDialog.

    I try in my code just now... when i use constructL() in my form, no menu items were displayed. but when i remove constructL() and add new menu using DynInitMenuPaneL() it works fine.

  14. #14
    Regular Contributor
    Join Date
    Jul 2006
    Posts
    50

    Re: Menu in Form fails to show up...

    Thanks ninidotnet for your help!

    I just tried again with the things,I could find the sollution.And exactly your code works.

    Just a minor mistake!

    Sohni.

  15. #15
    Registered User
    Join Date
    Apr 2007
    Posts
    8

    Re: Menu in Form fails to show up...

    Hi,
    I am trying to get the dynamic menu working, however I am having some trouble, the call to aMenuPane->SetItemDimmed is crashing with KERN-EXEC 3. What am I missing... Here is my code...

    Code:
    void setNewMenu()
    	{
    	CMenuUpdate* newMenu;
    
    	CjourneyAppUi* appUi;
    	
    	appUi = CjourneyAppUi::GetAppUi();
    	
    	CEikMenuPane aMenuPane(appUi);
    	
    
    
    	TRAPD(err, newMenu = CMenuUpdate::NewL());
    
    	newMenu->DynInitMenuPaneL(R_GENERIC_MENU_PANE1_MENU_PANE, &aMenuPane);
    	
    	}
    CMenuUpdate* CMenuUpdate::NewL()
    	{
    	  CMenuUpdate* self = new (ELeave) CMenuUpdate;
    	  CleanupStack::PushL(self);
    	  self->ConstructL();
    	  CleanupStack::Pop();
    	  return self;
    	}
    void CMenuUpdate::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane)
    {
    	CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);//r_emailform_menu R_EMAILFORM_MENU
    	if (aResourceId==R_GENERIC_MENU_PANE1_MENU_PANE)
    	{
    		aMenuPane->SetItemDimmed(EGenericViewNavigateMenuItemCommand,ETrue);//EForwad EFormExit
    		aMenuPane->SetItemDimmed(EGenericViewVolumeMenuItemCommand,ETrue);
    		aMenuPane->SetItemDimmed(EGenericViewPauseMenuItemCommand,ETrue);
    		aMenuPane->SetItemDimmed(EGenericViewResumeMenuItemCommand,ETrue);
    	}
    }
    void CMenuUpdate::ConstructL()
    	{
    	
    	}
    thanks
    Sunita...

Posting Permissions

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