Rediger

Del via


String Editor (C++)

A string table is a Windows resource that contains a list of IDs, values, and captions for all the strings of your application. For example, the status-bar prompts are located in the string table.

While developing an application, you can have several string tables — one for each language or condition. However, an executable module has only one string table. A running application can reference several string tables if you put the tables into different DLLs.

String tables make it easy to localize your application into different languages. If all strings are in a string table, you can localize the application by translating the strings (and other resources) without changing source code. This situation is more desirable than manually finding and replacing various strings in source files.

Note

Windows doesn't allow the creation of empty string tables. If you create a string table with no entries, it is deleted automatically when you save the resource file.

How To

The String Editor enables you:

To find a string resource in the string table

  1. Open the string table by double-clicking its icon in Resource View.

  2. Go to menu Edit > Find and Replace and choose Find.

  3. In the Find What box, select a previous search string from the drop-down list, or type the caption text or resource identifier of the string you want to find.

  4. Select any of the Find options and select Find Next.

Tip

To use regular expressions when searching files, use the Find in Files command in the Edit menu.

Type a regular expression to match a pattern or select the button to the right of the Find What box to display a list of regular search expressions. When you select an expression from this list, it is substituted as the search text in the Find What box.

If you use regular expressions, be sure the Use: Regular Expressions check box is selected.

To add or delete a string resource

You can quickly insert or delete entries into the string table using the String Editor. New strings are placed at the end of the table and are given the next available identifier. You can edit the ID, Value, or Caption properties in the Properties window as needed.

The String Editor makes sure you don't use an ID that's already in use. If you select an ID already in use, the String Editor will notify you and then assign a generic unique ID, for example IDS_STRING58113.

To add a string table entry

  1. Open the string table by double-clicking its icon in Resource View.

  2. Right-click within the string table and choose New String.

  3. In the String Editor, select an ID from the ID drop-down list or type an ID directly in place.

  4. Edit the Value, if necessary.

  5. Type an entry for the Caption.

    Note

    Null strings aren't allowed in Windows string tables. If you create an entry in the string table that's a null string, you'll receive a message asking you to Please enter a string for this table entry.

To delete a string table entry

Select the entry you want to delete and do one of the following:

  • Go to menu Edit > Delete.

  • Right-click the string to delete and choose Delete.

  • Press the Delete key.

To move a string from one resource script file to another

  1. Open the string tables in both .rc files.

  2. Right-click the string to move and choose Cut.

  3. Place the cursor in the target String Editor window.

  4. In the .rc file to which you want to move the string, right-click and choose Paste.

Note

If the ID or Value of the moved string conflicts with an existing ID or value in the destination file, either that ID or the Value of the moved string changes.

To change the properties of a string resource

You can use in-place editing to change the ID, Value, and Caption properties.

Note

You can also edit a string's properties in the Properties window.

To change a string or its identifier

  1. Open the string table by double-clicking its icon in Resource View.

  2. Select the string you want to edit and double-click the ID, Value, or Caption column, then you can:

    • Select an ID from the ID drop-down list, or type an ID directly in place.

    • Type a different number in the Value column.

    • Type edits in the Caption column.

To change the caption property of multiple string resources

  1. Open the string table by double-clicking its icon in Resource View.

  2. Select the strings you want to change by holding down the Ctrl key as you select each one.

  3. In the Properties Window, type a new value for the property you want to change.

  4. Press Enter.

To add formatting or special characters to a string resource

  1. Open the string table by double-clicking its icon in Resource View.

  2. Select the string you want to modify.

  3. In the Properties Window, add any of the standard escape sequences listed below to the text in the Caption box and press Enter.

    To get this... Type this...
    New line \n
    Carriage return \r
    Tab \t
    Backslash (\) \\
    ASCII character \ddd (octal notation)
    Alert (bell) \a

    Note

    The String Editor doesn't support the full set of escaped ASCI characters. You can only use those listed above.

Requirements

Win32

See also

Resource Editors Strings
About Strings
Customizing window layouts