String Tables

Tables of text strings may be defined within a resource script file for use by an application. A string table is defined using the STRINGTABLE keyword, as shown in Figure "String Table Resource Definition".

String tables may be used to contain titles, messages and other common text used by an application. The external definition of these strings makes it easy to change a title or message without modifying source code. String tables may also be used to contain menu bar or pulldown menu text for dynamic insertion by an application. Special characters such as mnemonic indicators and tab characters for columnating display may be incorporated into the string definition.

The symbolic name following the STRINGTABLE keyword identifies the string table and is used as a parameter when loading strings from the resource into application buffers using the WinLoadString() function. The PRELOAD keyword specifies that the resource will be incorporated into the application's main .EXE file, and is to be loaded into memory immediately rather than being loaded when called by the application.

Multiple string tables may be defined by an application. Each string table must have its own symbolic name (note that the same name may be used for a string table and another type of resource such as a menu bar) and is enclosed within the BEGIN and END keywords of a STRINGTABLE statement. Each string has its own symbolic name within the string table.

As mentioned above, strings are loaded from the string table into application buffers using the WinLoadString() function. For example, to load the string STR_MAINTITLE from the string table MAIN into a buffer named szTitle, the function shown in Figure "Loading a Text String Resource" is used.

The WinLoadString() function returns an unsigned integer representing the number of characters loaded into the target buffer. Once loaded, the buffer may then be manipulated using standard programming language functions, or used as a parameter to other Presentation Manager function calls.


[Back: Menu Bars and Pulldown Menus]
[Next: Accelerator Tables]