You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c5efe89
Browse filesBrowse the repository at this point in the historyBrowse files
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.
11
13
12
-
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. For more information, see [Changing Unassigned Symbols](../windows/changing-unassigned-symbols.md).
14
+
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.
13
15
14
16
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.
15
17
16
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*.
17
19
18
-
## To change a resource's symbol name (ID)
19
-
20
-
1. In [Resource View](../windows/resource-view-window.md), select the resource.
21
-
22
-
> [!NOTE]
23
-
> 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).
24
-
25
-
1. In the **Properties** window, type a new symbol name or select from the list of existing symbols in the **ID** box.
26
-
27
-
If you type a new symbol name, it is automatically assigned a value.
28
-
29
-
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. For more information, see [Changing Unassigned Symbols](../windows/changing-unassigned-symbols.md).
30
-
31
20
### Symbol name restrictions
32
21
33
22
The restrictions on symbol names are as follows:
@@ -56,20 +45,18 @@ Symbol names have descriptive prefixes that indicate the kind of resource or obj
56
45
|Strings|IDS_|String in the string table|
57
46
|MFC|AFX_|Reserved for predefined MFC symbols|
58
47
59
-
## To change a symbol value assigned to a single resource or object
48
+
###To change a resource's symbol name (ID)
60
49
61
50
1. In [Resource View](../windows/resource-view-window.md), select the resource.
62
51
63
52
> [!NOTE]
64
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).
65
54
66
-
1. In the **Properties** window, type the symbol name followed by an equal sign and an integer in the **ID** box, for example:
55
+
1. In the **Properties** window, type a new symbol name or select from the list of existing symbols in the **ID** box.
67
56
68
-
```
69
-
IDC_EDITNAME=5100
70
-
```
57
+
If you type a new symbol name, it is automatically assigned a value.
71
58
72
-
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.
59
+
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.
73
60
74
61
### Symbol value restrictions
75
62
@@ -108,6 +95,27 @@ Here are some limitations of symbol values:
108
95
109
96
For more information on number ranges, see [TN023: Standard MFC Resources](../mfc/tn023-standard-mfc-resources.md).
110
97
98
+
### To change a symbol value assigned to a single resource or object
99
+
100
+
1. In [Resource View](../windows/resource-view-window.md), select the resource.
101
+
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
+
105
+
1. In the **Properties** window, type the symbol name followed by an equal sign and an integer in the **ID** box, for example:
106
+
107
+
```
108
+
IDC_EDITNAME=5100
109
+
```
110
+
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
+
111
119
## To change the name of the resource symbol header file
112
120
113
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.
@@ -117,11 +125,79 @@ For more information on number ranges, see [TN023: Standard MFC Resources](../mf
117
125
118
126
1. In the **Symbol header file** box, type the new name for the include file.
119
127
128
+
129
+
# Changing or Deleting Unassigned Symbols
130
+
131
+
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.
132
+
133
+
## To change an unassigned symbol
134
+
135
+
1. In the **Name** box, select the unassigned symbol, and choose **Change**.
136
+
137
+
1. Edit the symbol's name or value in the boxes provided in the **Change Symbol** dialog box.
138
+
139
+
> [!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).
141
+
142
+
## To delete an unassigned (unused) symbol
143
+
144
+
In the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md), select the symbol that you want to delete, and choose **Delete**.
145
+
146
+
> [!NOTE]
147
+
> 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.
148
+
149
+
# Including Shared (Read-Only) or Calculated Symbols
150
+
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.
152
+
153
+
One reason you may want to use read-only symbol definitions is for symbol files that you plan to share among several projects.
154
+
155
+
You can also use included symbol files when you have existing resources with symbol definitions that use expressions rather than simple integers to define the symbol value. For example:
156
+
157
+
```cpp
158
+
#define IDC_CONTROL1 2100
159
+
#define IDC_CONTROL2 (IDC_CONTROL1+1)
160
+
```
161
+
162
+
The environment will correctly interpret these calculated symbols as long as:
163
+
164
+
- The calculated symbols are placed in a read-only symbols file.
165
+
166
+
- Your resource file contains resources to which these calculated symbols are already assigned.
167
+
168
+
- A numeric expression is expected.
169
+
170
+
> [!NOTE]
171
+
> If a string or a numeric expression is expected, then the expression is not evaluated.
172
+
173
+
### To include shared (read-only) symbols in your resource file
174
+
175
+
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.
176
+
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
+
180
+
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.
181
+
182
+
Do not call the file `Resource.h`, since that is the filename normally used by the main symbol header file.
183
+
184
+
> [!NOTE]
185
+
> **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.
186
+
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.
188
+
189
+
1. Place the symbols in the file you specified.
190
+
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.
0 commit comments