Symbian C++ Programming Tutorial > *5. Using Resources

*5. Using Resources

Symbian GUI applications use resources. This is a matter of fact. A minimal GUI application is comprised of a compiled executable file (e.g. Base.app) and a compiled resorce file (e.g. Base.rsc). Resources are used to define a lot of things. Mainly gui elements, but also message string allowing for an easy internationalization.

To create the compiled resource, you write a .rss file, then compile it with the special tool rcomp (meaning, of courcse, Rescource COMPiler). Well, the resource source is not only an hello.rss. There are some other files that need to be written along the .rss.

The file really is firstly preprocessed using the usual cpp then compiled to generate the .rsc. In the process of compiling a .rss it is usual #include files with diverse extensions: we have .rh, .hrh and .loc. Also the .loc includes other files with extensions .l01, .l02 etc.

Let's explain these files. Each of them contains different things. A resoruce file .rss contain resource definitions. We will see them later, but is something like "this menu has this name". The important thing to know is that resource definitions are of many different types. A resource declaration must be defined. There are standard definitions and these are in the .rh files.

Also in a resource file there is a need for localized strings. There are usually stored in the .loc file. This file conditionally include .l01, .l02 depending on the target natural language. There is a coding where 01 is UK English, 02 is French and so on.

Lastly there is a need for some constants that must be shared with the C++ source code. This is the purpose of the .hrh source file. This file ususally contains ONLY "enumeration" that are defined in a syntax shared both by the rcomp and the C++ compiler. More on it later.

At this point you can compile your .rss, and you will obtain two files: a .rsc and a .rsg. The .rsg is a special file contaning some numeric code, generated by the resource compiler, that must be shared also with the C++ compiler. So an the end the .app will use declaration present both in the .hrh (defined by the programmer) and the .rsg (generated by the rcomp). This sharing is the way the application refer to the resources and use them.

Submenu

Symbian C++ Programming Tutorial