Using Character String Resources

The character string resources are defined in your resource script using the keyword STRINGTABLE:

STRINGTABLE [load option] [memory option]

{

nID1, "character string 1"

nID2, "character string 2"

[other string definitions]

}

The resource script can contain only one string table. LOADONCALL is the default load option; MOVEABLE and DISCARDABLE are the default memory options. Each string can be only one line long with a maximum of 255 characters. The strings cannot contain any C-style control characters except for \t (tab). However, the strings can contain octal constants:

Tab \011
Linefeed \012
Carriage return \015

These control characters are recognized by the DrawText and MessageBox functions.

Your program can use the LoadString call to copy a string resource into a buffer in the program's data segment:

LoadString (hInstance, nID, lpszBuffer, nMaxLength) ;

The nID parameter refers to the ID number that precedes each string in the resource script; lpszBuffer is a far (or long) pointer to a character array that receives the character string; and nMaxLength is the maximum number of characters to transfer into the lpszBuffer. The string ID numbers that precede each string are generally macro identifiers defined in a header file. Many Windows programmers use the prefix IDS_ to denote an ID number for a string. Sometimes a filename or other information must be embedded in the string when the string is displayed. In this case you put C formatting characters in the string and use it as a formatting string in sprintf or wsprintf.