×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    58

    Problems with CBA resource in 2nd Resource File.

    I'm relatively new to Symbian, and for the past several days have been pouring over the API relating to multiple resource files. Specifically I wanted to dynamically set a menu bar located in a second resource file. I managed to get that working using the following statements:

    /* Add the second resource file */
    TInt offset = CEikonEnv::Static()->AddResourceFileL( resourceFullName );

    /* Set the menu */
    CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
    menuBar->SetMenuTitleResourceId( R_MENUBAR_ID );

    /* Delete the second resource file */
    CEikonEnv::Static()->DeleteResourceFile( offset );

    So far so good. My next step was to attempt to use a CBA resource defined in the same 2nd resource file. I placed the following statement after the call to SetMenuTitleResourceId().

    /* Set the CBA */
    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
    cba->SetCommandSetL( R_CBA_ID );

    For some reason the call to SetCommandSetL() results in a Panic CONE 14 (no resource found). And if I put the CBA resource into the main resource file the statement works as expected. I'm surprized by this, since the call to SetMenuTitleResourceId() seems to work properly with the second resource file. Is there any reason that CBA resources would be treated differently than MENU_BAR resources with respect to added resource files?

    Any help would be appreciated.

    Thanks.

    Colin

  2. #2
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    58

    Problems with 2nd Resource in 2nd Resource File.

    Upon further experimentation, my problems seem to stem from the fact that I'm trying to use a resource from my second resource file that _is_not_ the first resource in that file. So my original working case...

    /* Add the second resource file */
    TInt offset = CEikonEnv::Static()->AddResourceFileL( resourceFullName );

    /* Set the menu */
    CEikMenuBar* menuBar = iEikonEnv->AppUiFactory()->MenuBar();
    menuBar->SetMenuTitleResourceId( R_MENUBAR_ID );

    /*----Attempt to display menu here-----*/

    /* Delete the second resource file */
    CEikonEnv::Static()->DeleteResourceFile( offset );

    ... only works when R_MENUBAR_ID is the first resource in that file. At least, the first resource after the RSS_SIGNATURE, and the TBUF document name.

    I can almost see how this might be happening given the RResourceFile and TResourceReader API, but since all I'm calling is SetMenuTitleResourceId(), shouldn't the Symbian Framework just figure out where that resource is? It should be able to determine which resource file to use based on the top 20 bits of the resource id, and then use the other 12 bits as an offset into that file.

    I'm not a dumb guy, but this resource handling seems way too complicated for me. What am I missing?

    -c

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    58

    My bad.

    You know, I was tired and it was friday. I was actually reading from an old resource file, while building to a newer name. Stupid rookie mistake.

    -c

  4. #4
    Registered User
    Join Date
    Jan 2004
    Posts
    23
    Hi,

    I want to know how you use this code:
    TInt offset = CEikonEnv::Static()->AddResourceFileL(resourcefullname);

    Especially, what is "resourcefullname".

    A silly question: if my resource file names "myapp.rsg", then can I use like this:
    TInt offset = CEikonEnv::Static()->AddResourceFileL(myapp.rsg);

    Thanks

  5. #5
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    58
    The resource full name is the fully qualified path to the resource. Your resources should have a .rsc extension (the .rsg is included to provide the resource ids).

    So:

    TInt offset = CEikonEnv::Static()->AddResourceFileL(
    _L( "Z:\\System\\apps\\myapp\\myapp.rsc" ) );

    might work.

    -c

  6. #6
    Registered User
    Join Date
    Jan 2004
    Posts
    23
    Hi colinlawrence,

    First, Thanks for your kind reply warmly.

    "TInt offset = CEikonEnv::Static()->AddResourceFileL(
    _L( "Z:\\System\\apps\\myapp\\myapp.rsc" ) );"
    My App runs the following code without errors.

    Since I want to load the new CBA buttons defined in the second
    resource file myapp.rsc, I just use the following code
    "CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();"
    in void CMyAppUi::ConstructL() or in HandleCommandL(). However, the
    build process failed this time. I know the problem comes from this code,
    but I do not know why?

    Could you tell a little more how to dynamically load CBA buttons?
    Forgive my stupid...

    Thanks again.

Posting Permissions

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