Skip to content

Commit 01418c8

Browse files
author
msebolt
committed
touch-ups
1 parent c5efe89 commit 01418c8

1 file changed

Lines changed: 32 additions & 50 deletions

File tree

‎docs/windows/changing-a-symbol-or-symbol-name-id.md‎

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ ms.assetid: 26541832-8dba-4177-b642-e08f94502ea7
77
---
88
# How to: Manage Symbols
99

10-
## Changing a Symbol
11-
1210
When you create a new resource or resource object, the development environment assigns it a default symbol name, for example, IDD_DIALOG1. You can use the [Properties Window](/visualstudio/ide/reference/properties-window) to change the default symbol name or to change the name of any symbol already associated with a resource.
1311

1412
For symbols associated with a single resource, you can also use the **Properties** window to change the symbol value. You can use the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md) to change the value of symbols not currently assigned to a resource.
1513

1614
Normally all symbol definitions are saved in `Resource.h`. However, you may need to change this include filename so that you can, for example, work with more than one resource file in the same directory.
1715

18-
For information on adding resources to managed projects, please see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*.
16+
For information on adding resources to managed projects, see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*.
17+
18+
> [!NOTE]
19+
> If your project doesn't already contain an .rc file, see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
1920
20-
### Symbol name restrictions
21+
## Symbol name restrictions
2122

2223
The restrictions on symbol names are as follows:
2324

2425
- All [symbols](../windows/symbols-resource-identifiers.md) must be unique within the scope of the application. This prevents conflicting symbol definitions in the header files.
2526

2627
- Valid characters for a symbol name include A-Z, a-z, 0-9, and underscores ( _ ).
2728

28-
- Symbol names cannot begin with a number and are limited to 247 characters.
29+
- Symbol names can't begin with a number and are limited to 247 characters.
2930

30-
- Symbol names cannot contain spaces.
31+
- Symbol names can't contain spaces.
3132

32-
- Symbol names are not case sensitive, but the case of the first symbol definition is preserved. The header file that defines the symbols is used by both the resource compiler/editor and C++ program(s) to refer resources defined in a resource file. For two symbol names that differ only in case, the C++ program will see two separate symbols while the resource compiler/editor will see both names as referring to one single symbol.
33+
- Symbol names aren't case-sensitive, but the case of the first symbol definition is preserved. The header file that defines the symbols is used by both the resource compiler/editor and C++ program(s) to refer resources defined in a resource file. For two symbol names that differ only in case, the C++ program will see two separate symbols while the resource compiler/editor will see both names as referring to one single symbol.
3334

3435
> [!NOTE]
3536
> If you do not follow the standard symbol name scheme (ID*_[keyword]) outlined below, and your symbol name happens to be the same as a keyword known to the resource script compiler, trying to build the resource script file will result in seemingly random error generation that is difficult to diagnose. To prevent this, adhere to the standard naming scheme.
@@ -45,20 +46,17 @@ Symbol names have descriptive prefixes that indicate the kind of resource or obj
4546
|Strings|IDS_|String in the string table|
4647
|MFC|AFX_|Reserved for predefined MFC symbols|
4748

48-
### To change a resource's symbol name (ID)
49+
### To change a symbol name (ID)
4950

5051
1. In [Resource View](../windows/resource-view-window.md), select the resource.
5152

52-
> [!NOTE]
53-
> If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
54-
5553
1. In the **Properties** window, type a new symbol name or select from the list of existing symbols in the **ID** box.
5654

57-
If you type a new symbol name, it is automatically assigned a value.
55+
If you type a new symbol name, it's automatically assigned a value.
5856

5957
You can use the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md) to change the names of symbols not currently assigned to a resource.
6058

61-
### Symbol value restrictions
59+
## Symbol value restrictions
6260

6361
A symbol value can be any integer expressed in the normal manner for #define preprocessor directives. Here are some examples of symbol values:
6462

@@ -71,84 +69,65 @@ A symbol value can be any integer expressed in the normal manner for #define pre
7169

7270
Symbol values for resources (accelerators, bitmaps, cursors, dialog boxes, icons, menus, string tables, and version information) must be decimal numbers in the range from 0 to 32,767 (but cannot be hexadecimal). Symbol values for parts of resources, such as dialog box controls or individual strings in the string table, can be from 0 to 65,534 or from -32,768 to 32,767.
7371

74-
Resource symbols are 16 bit numbers. You may enter them as signed or unsigned, however, they are used internally as unsigned integers. So negative numbers will be cast to their corresponding positive value.
72+
Resource symbols are 16-bit numbers. You may enter them as signed or unsigned, however, they're used internally as unsigned integers. So negative numbers will be cast to their corresponding positive value.
7573

7674
Here are some limitations of symbol values:
7775

7876
- The Visual Studio development environment and MFC use some number ranges for special purposes. All numbers with the most significant bit set (-32,768 to -1 or 32,768 to 65,534, depending on sign) are reserved by MFC.
7977

80-
- You cannot define a symbol value using other symbol strings. For example, the following symbol definition is not supported:
78+
- You can't define a symbol value using other symbol strings. For example, the following symbol definition isn't supported:
8179

8280
```cpp
8381
#define IDC_MYEDIT IDC_OTHEREDIT //not supported
8482
```
8583

86-
- You cannot use preprocessor macros with arguments as value definitions. For example:
84+
- You can't use preprocessor macros with arguments as value definitions. For example:
8785
8886
```cpp
8987
#define IDD_ABOUT ID(7) //not supported
9088
```
9189
92-
is not a valid expression regardless of what `ID` evaluates to at compile time.
90+
isn't a valid expression regardless of what `ID` evaluates to at compile time.
9391

9492
- Your application may have an existing file containing symbols defined with expressions. For more information on how to include the symbols as read-only symbols, see [Using Shared (Read Only) or Calculated Symbols](../windows/including-shared-read-only-or-calculated-symbols.md).
9593

9694
For more information on number ranges, see [TN023: Standard MFC Resources](../mfc/tn023-standard-mfc-resources.md).
9795

98-
### To change a symbol value assigned to a single resource or object
96+
### To change a symbol value
9997

10098
1. In [Resource View](../windows/resource-view-window.md), select the resource.
10199

102-
> [!NOTE]
103-
> If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
104-
105100
1. In the **Properties** window, type the symbol name followed by an equal sign and an integer in the **ID** box, for example:
106101

107102
```
108103
IDC_EDITNAME=5100
109104
```
110105
111-
The new value is stored in the symbol header file the next time you save the project. Only the symbol name remains visible in the ID box; the equal sign and value are not displayed after they are validated.
112-
113-
114-
115-
116-
117-
118-
119-
## To change the name of the resource symbol header file
106+
The new value is stored in the symbol header file the next time you save the project. Only the symbol name remains visible in the ID box; the equal sign and value aren't displayed after they're validated.
120107
121-
1. In [Resource View](../windows/resource-view-window.md), right-click your .rc file and choose [Resource Includes](../windows/resource-includes-dialog-box.md) from the shortcut menu.
122-
123-
> [!NOTE]
124-
> If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
125-
126-
1. In the **Symbol header file** box, type the new name for the include file.
127-
128-
129-
# Changing or Deleting Unassigned Symbols
108+
## Change or delete unassigned symbols
130109
131110
While in the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md), you can edit or delete existing symbols that aren't already assigned to a resource or object.
132111
133-
## To change an unassigned symbol
112+
### To change an unassigned symbol
134113
135114
1. In the **Name** box, select the unassigned symbol, and choose **Change**.
136115
137116
1. Edit the symbol's name or value in the boxes provided in the **Change Symbol** dialog box.
138117
139118
> [!NOTE]
140-
> To change a symbol that *is* assigned to a resource or object, you must use the resource editor or **Properties** window. For more information, see [Changing a Symbol or Symbol Name](../windows/changing-a-symbol-or-symbol-name-id.md).
119+
> To change a symbol that *is* assigned to a resource or object, you must use the resource editor or **Properties** window.
141120
142-
## To delete an unassigned (unused) symbol
121+
### To delete an unassigned (unused) symbol
143122
144123
In the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md), select the symbol that you want to delete, and choose **Delete**.
145124
146125
> [!NOTE]
147126
> Before deleting an unused symbol in a resource file, make sure it is not used elsewhere in the program or by resource files included at compile time.
148127
149-
# Including Shared (Read-Only) or Calculated Symbols
128+
## Include shared (read-only) or calculated symbols
150129
151-
The first time the development environment reads a resource file created by another application, it marks all included header files as read-only. Subsequently, you can use the [Resource Includes dialog box](../windows/resource-includes-dialog-box.md) to add additional read-only symbol header files.
130+
The first time the development environment reads a resource file created by another application, it marks all included header files as read-only. Though you can use the [Resource Includes dialog box](../windows/resource-includes-dialog-box.md) to add additional read-only symbol header files.
152131
153132
One reason you may want to use read-only symbol definitions is for symbol files that you plan to share among several projects.
154133
@@ -174,24 +153,27 @@ The environment will correctly interpret these calculated symbols as long as:
174153

175154
1. In [Resource View](../windows/resource-view-window.md), right-click your .rc file and choose [Resource Includes](../windows/resource-includes-dialog-box.md) from the shortcut menu.
176155

177-
> [!NOTE]
178-
> If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
179-
180156
1. In the **Read-only symbol directives** box, use the `#include` compiler directive to specify the file where you want the read-only symbols to be kept.
181157

182-
Do not call the file `Resource.h`, since that is the filename normally used by the main symbol header file.
158+
Don't call the file `Resource.h`, since that is the filename normally used by the main symbol header file.
183159

184160
> [!NOTE]
185161
> **Important** What you type in the Read-Only symbol directives box is included in the resource file exactly as you type it. Make sure what you type does not contain any spelling or syntax errors.
186162
187-
Use the **Read-only symbol directives** box to include files with symbol definitions only. Do not include resource definitions; otherwise, duplicate resource definitions will be created when the file is saved.
163+
Use the **Read-only symbol directives** box to include files with symbol definitions only. Don't include resource definitions; otherwise, duplicate resource definitions will be created when the file is saved.
188164

189165
1. Place the symbols in the file you specified.
190166

191-
The symbols in files included in this way are evaluated each time you open your resource file, but they are not replaced on the disk when you save your file.
167+
The symbols in files included in this way are evaluated each time you open your resource file, but they aren't replaced on the disk when you save your file.
192168

193169
1. Select **OK**.
194170

171+
### To change the name of the resource symbol header file
172+
173+
1. In [Resource View](../windows/resource-view-window.md), right-click your .rc file and choose [Resource Includes](../windows/resource-includes-dialog-box.md) from the shortcut menu.
174+
175+
1. In the **Symbol header file** box, type the new name for the include file.
176+
195177
## Requirements
196178

197179
Win32

0 commit comments

Comments
 (0)