How to read from language-based resource file...

You need to change:

First open your language file, myapplication.l01 (english) for example and add your strings there.

[myapplication.l01]

...

#define qtn_appl_test "Test"
#define qtn_appl_exit "Exit"

// example caption strings for app
#define qtn_app_caption_string "MyApplication"
#define qtn_app_short_caption_string "MyApplication"

// Your own strings
#define qtn_app_my_text "Hello World"

Next open .rss file and add buf (string) resources there..

[myapplication.rss]

...

RESOURCE TBUF r_my_text { buf = qtn_app_my_text;}

// end of file
The last thing is just to use those resources in your code. Multilingual installation will take care of that the language is correct. See Multilingual application setup
[MyaApplicationContainer.cpp]

...

#include <MyApplication.rsg>

...

TBuf<30> buf;
CEikonEnv::Static()->ReadResource( buf, R_MY_TEXT );

...

With these steps the string resource is ready to use. There can be lots of other ways to do this, but this is my way ;)

The other way to read resource and a way to copy its content to a TBuf:

[MyApplicationContainer.cpp]

...

#include <MyApplication.rsg>

...

HBufC* hBuf = CEikonEnv::Static()->AllocReadResourceLC( R_MY_TEXT );

...

TBuf<30> buf = hBuf->Des();
CleanupStack::PopAndDestroy() // hBuf

...

© 2005 symbian.louhos.com [back to index]