Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 3: Windows Resources Visual C++ and MFC Fundamentals


3.8 The String Table..............................................................................................


3.8.1 Description...............................................................................................


A string table is a list of all object strings that are part of an application. It allows any part
of the program to refer to that table when a common string is needed. The advantage of a
string table is that it can be used as a central place when to store or retrieve strings that
any other objects of the application may need. These can include the titles or captions of
Windows controls, the formatting strings used inside of functions or controls.

3.8.2 Creating and Using a String Table.......................................................


When you install Microsoft Visual C++, it also installs a lot of strings that are readily
available for your applications. Most of the time, you will also need to create additional
or your own strings. To create a string table, from the Add Resource dialog box, click
String Table and click New. Each item of the table is made of three sections: an
identifier, a constant natural number, and a caption.

To add a new item, you can right-click in the String Table window and click New String.
You can also double-click the last empty row in the window. You can also press Insert.
Either case, the String Properties window would display.

You can either type a new ID or select an existing ID from the ID combo box. Then type
the associated string in the Caption box. Continually, you would have created a String
Table:

The identifier, ID, is the same type of ID used when creating the resources earlier. In fact,
most of the IDs used on a string table are shared among resources, as we will learn when
reviewing the CFrameWnd::LoadFrame() method.

The value column contains a constant LONG integer for each identifier. You will not
need to specify this number when using the String Table window; Visual C++
automatically and independently creates and manages those numbers. If you want to
create a string and specify your own number, on the main menu of MSVC 6, you can
click View -> Resource Symbols...
Free download pdf