×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,349

    Thumbs up How to change Menu Bar on Runtime

    Hi,

    I am trying to add Menu items dynamically and to change the MenuBar dynamically.
    There are already some menu items in the program, I want to append some more dynamically.
    in the Rss file I have added like this.
    HTML Code:
    MENU_ITEM
    {
    txt="Check";
    // command = ENMsg;
    cascade=r_add_menu;
    },
    MENU_ITEM
    {
    txt="Radio";
    // command = ENMsg;
    cascade=r_add_Radio;
    }
    
    RESOURCE MENU_PANE r_add_menu
    	{
    	items =
    		{
    
    		};
    	}
    
    RESOURCE MENU_PANE r_add_Radio
    	{
    	items =
    		{
    		MENU_ITEM
    			{
    			command = EAnotherCmdA;
    			txt= "Radio Deleted";
    			flags =EEikMenuItemRadioMiddle;
    			}
    
    		};
    	}
    In the AppUi.cpp file
    HTML Code:
    void CMyXmlParserAppUi::DynInitMenuPaneL(TInt aResourceId,
    		CEikMenuPane* aMenuPane)
    	{
    if (R_ADD_MENU == aResourceId)
    	      {
    	        
    	        // code for dynamic check box
    	      
    	      
    	      for(TInt i=0;i<3;i++)
    	    	  {
    	        CEikMenuPaneItem::SData data;
    	        data.iText.Copy(_L("Dynamic Menu"));
    	        data.iCommandId = EDynamicMenu;
    	        data.iCascadeId=0;
    	        data.iFlags= EEikMenuItemCheckBox     ;
    	        data.iExtraText=KNullDesC;
    	        aMenuPane->AddMenuItemL(data);*/
    	    	  }
    	        
    	        
    	        
    	     
    	         
    	        aMenuPane->SetItemButtonState( EDynamicMenu,EEikMenuItemSymbolOn  ); 
    	       
    	                              
    	      }
    	 
    	 
    	 if (R_ADD_RADIO == aResourceId)
    	       {
    	       
    	       // code for dynamic radio button 
    	       
    	         aMenuPane-> DeleteMenuItem( EAnotherCmdA );
    	         
    	         
    	         for(TInt i=0;i<3;i++)
    	        	 {
    	         CEikMenuPaneItem::SData data4;
    	         data4.iText.Copy(_L("Dynamic Menu4"));
    	         data4.iCommandId = EDynamicMenu4;
    	         data4.iCascadeId=0;
    	         data4.iFlags= EEikMenuItemRadioStart ;
    	         data4.iExtraText=KNullDesC;
    	         aMenuPane->AddMenuItemL(data4);
    	        	 }
    	        
    	         
    	         
    	         
    	     
    	          
    	         aMenuPane->SetItemButtonState( EDynamicMenu4,EEikMenuItemSymbolOn  ); 
    	        
    	                               
    	       }
    }
    And trying to change the Menu Bar on runtime as this
    HTML Code:
    CEikonEnv::Static()->AppUiFactory()->MenuBar()->StopDisplayingMenuBar();
    CEikonEnv::Static()->AppUiFactory()->MenuBar()->SetMenuTitleResourceId(R_MENUBAR1);
    When I run the program the default menu bar come fine, but when I change the menu bar it doesn't changes and the emulator crach if I click on the left softkey(option). I am getting an error message "Panic BAFL 4"
    when I debug the code I found this message
    "5 E32Main() C:\Symbian\Carbide\MyXmlParser_Phone_ML1\MyXmlParserWeb\src\MyXmlParser.cpp:29 0x004011d4 "
    and the problem occurs at

    HTML Code:
    GLDEF_C TInt E32Main()
    	{
    	return EikStart::RunApplication( NewApplication );
    	
    	}

    Please suggest me how can I change the menu bar on runtime.

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: How to change Menu Bar on Runtime

    Hi,

    Where is R_MENUBAR1 declared/defined?
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: How to change Menu Bar on Runtime

    Note that DynInitMenuPaneL and SetMenuTitleResourceId and radio buttons in menus are three completely different things. Check one thing at a time.

  4. #4
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,349

    Re: How to change Menu Bar on Runtime

    R_MENUBAR1 is defined in rss file
    HTML Code:
    RESOURCE EIK_APP_INFO
    	{
    	menubar = r_menubar1;
    	//cba=R_AVKON_SOFTKEYS_OPTIONS_BACK;
    	}
    
    
    RESOURCE MENU_BAR r_menubar1
    	{
    	titles =
    		{
    		MENU_TITLE
    			{menu_pane = r_menu1;}
    
    		};
    	}
    
    RESOURCE MENU_PANE r_menu1
    	{
    	items =
    		{
    
    		};
    	}
    
    RESOURCE MENU_PANE r_cascade
    	{
    	items =
    		{
    
    		MENU_ITEM
    			{
    			command = EAnotherCmdA;
    			// txt= "Radio Deleted";
    			flags =EEikMenuItemRadioMiddle;
    			}
    
    		};
    	}
    
    RESOURCE MENU_PANE r_cascade1
    	{
    	items =
    		{
    
    		MENU_ITEM
    			{
    			command = EAnotherCmdB;
    			flags = EEikMenuItemCheckBox;
    			}
    
    		};
    	}
    and declared in .rsg file

    I have also checked and found the if I don't cascade any items in the r_menuThe program works fine and can change the Menu Bar also. why Its creating problem when I cascade items in RESOURCE MENU_PANE r_menu, where r_menu is the default menu pane .

    Please suggest me. how to resolve this problem, an to change the menu bar.

  5. #5
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,349

    Re: How to change Menu Bar on Runtime

    please help someone.

  6. #6
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: How to change Menu Bar on Runtime

    Hi,

    Here is an example worth looking. I am not able to map your resource file.
    I feel, you are not cascading under MenuItem. flow should be something like this menu_bar{menu_title{menu_Pane {Menu Item{cascade}}}}
    (Ignore syntax errors just look at the mappings).

    Please go over the code and map your code to it. Add stuff in resource file, one at a time, so that you know where it goes wrong.

    If you want you can attach your resource file over here, so that somebody can look into it.
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

Similar Threads

  1. Need help to change menu colors programmatically
    By sudeepa2005 in forum Symbian C++
    Replies: 1
    Last Post: 2009-03-18, 21:36
  2. dynemic menu
    By pankaj gupta55 in forum Symbian C++
    Replies: 1
    Last Post: 2008-09-20, 11:33
  3. Dynamically change menu bar?
    By hanwang in forum Symbian User Interface
    Replies: 7
    Last Post: 2008-03-21, 06:48
  4. S60: Change AIF at runtime?
    By fsiegel in forum Symbian C++
    Replies: 5
    Last Post: 2006-06-13, 19:20
  5. using menu bar kills bluetooth inquiry
    By sfitw in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-06-08, 04:36

Posting Permissions

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