Edit

Share via


How to: Create Symbols (C++)

When you're beginning a new project, you may find it convenient to map out the symbol names you need before creating the resources to which they'll be assigned.

Note

If your project doesn't already contain an .rc file, see How to: Create Resources.

The Resource Symbols dialog box allows you to add new resource symbols, change the symbols that are displayed, or skip to the location in the source code where a symbol is in use.

The dialog box contains the following properties:

Property Description
Name Displays the name of the symbol.

For more information, see Symbol Name Restrictions.
Value Displays the numeric value of the symbol.

For more information, see Symbol Value Restrictions.
In Use When selected, specifies that the symbol is being used by one or more resources.

The resource or resources are listed in the Used by box.
Show read-only symbols When selected, displays read-only resources.

By default, the Resource Symbol dialog box displays only the modifiable resources in your resource script file, but with this option selected, modifiable resources appear in bold text and read-only resources appear in plain text.
Used by Displays the resource or resources using the symbol selected in the symbols list.

To move to the editor for a given resource, select the resource in the Used by box and choose View Use.
New Opens the New Symbol dialog box that enables you to define the name and, if necessary, a value for a new symbolic resource identifier.
Change Opens the Change Symbol dialog box that allows you to change the name or value of a symbol.

If the symbol is for a control or resource in use, the symbol can be changed only from the corresponding resource editor. For more information, see Manage Symbols.
View Use Opens the resource that contains the symbol in the corresponding resource editor.

Create Symbols

To create a new symbol

  1. In the Resource Symbols dialog box, choose New.

  2. In the Name box, type a symbol name.

  3. Accept the assigned symbol value or type a new value in the Value box.

  4. Select OK to add the new symbol to the symbol list.

Note

If you type a symbol name that already exists, a message box appears stating that a symbol with that name is already defined. You can't define two or more symbols with the same name, but you can define different symbols with the same numeric value.

To view resource symbols

In Resource View, right-click your .rc file and select Resource Symbols to view a resource symbol table in the Resource Symbols dialog box.

Note

To see predefined symbols, check the Show read-only symbols check box.

To open the resource editor for a given symbol

When you're browsing symbols in the Resource Symbols, you may want more information on how a particular symbol is used. The View Use button provides a quick way to get this information.

  1. In the Resource Symbols dialog box in the Name box, select a symbol.

  2. In the Used By box, select the resource type that interests you.

  3. Select the View Use button.

    The resource appears in the appropriate editor window.

Requirements

Win32

See also

Resource Identifiers (Symbols)
How to: Manage Symbols
Predefined Symbol IDs