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 2832f1f
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
11
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).
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.
13
13
14
14
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
15
16
-
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
17
18
-
## To change a resource's symbol name (ID)
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).
19
20
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
-
### Symbol name restrictions
21
+
## Symbol name restrictions
32
22
33
23
The restrictions on symbol names are as follows:
34
24
35
25
- 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.
36
26
37
27
- Valid characters for a symbol name include A-Z, a-z, 0-9, and underscores ( _ ).
38
28
39
-
- 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.
40
30
41
-
- Symbol names cannot contain spaces.
31
+
- Symbol names can't contain spaces.
42
32
43
-
- Symbol names are not casesensitive, 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.
44
34
45
35
> [!NOTE]
46
36
> 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.
@@ -56,22 +46,17 @@ Symbol names have descriptive prefixes that indicate the kind of resource or obj
56
46
|Strings|IDS_|String in the string table|
57
47
|MFC|AFX_|Reserved for predefined MFC symbols|
58
48
59
-
## To change a symbol value assigned to a single resource or object
49
+
###To change a symbol name (ID)
60
50
61
51
1. In [Resource View](../windows/resource-view-window.md), select the resource.
62
52
63
-
> [!NOTE]
64
-
> 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
-
66
-
1. In the **Properties** window, type the symbol name followed by an equal sign and an integer in the **ID** box, for example:
53
+
1. In the **Properties** window, type a new symbol name or select from the list of existing symbols in the **ID** box.
67
54
68
-
```
69
-
IDC_EDITNAME=5100
70
-
```
55
+
If you type a new symbol name, it's automatically assigned a value.
71
56
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.
57
+
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
58
74
-
### Symbol value restrictions
59
+
## Symbol value restrictions
75
60
76
61
A symbol value can be any integer expressed in the normal manner for #define preprocessor directives. Here are some examples of symbol values:
77
62
@@ -84,36 +69,108 @@ A symbol value can be any integer expressed in the normal manner for #define pre
84
69
85
70
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.
86
71
87
-
Resource symbols are 16bit 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.
88
73
89
74
Here are some limitations of symbol values:
90
75
91
76
- 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.
92
77
93
-
- 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:
94
79
95
80
```cpp
96
81
#defineIDC_MYEDIT IDC_OTHEREDIT //not supported
97
82
```
98
83
99
-
- 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:
100
85
101
86
```cpp
102
87
#define IDD_ABOUT ID(7) //not supported
103
88
```
104
89
105
-
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.
106
91
107
92
- 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).
108
93
109
94
For more information on number ranges, see [TN023: Standard MFC Resources](../mfc/tn023-standard-mfc-resources.md).
110
95
111
-
## To change the name of the resource symbol header file
96
+
### To change a symbol value
97
+
98
+
1. In [Resource View](../windows/resource-view-window.md), select the resource.
99
+
100
+
1. In the **Properties** window, type the symbol name followed by an equal sign and an integer in the **ID** box, for example:
101
+
102
+
```
103
+
IDC_EDITNAME=5100
104
+
```
105
+
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.
107
+
108
+
## Change or delete unassigned symbols
109
+
110
+
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.
111
+
112
+
### To change an unassigned symbol
113
+
114
+
1. In the **Name** box, select the unassigned symbol, and choose **Change**.
115
+
116
+
1. Edit the symbol's name or value in the boxes provided in the **Change Symbol** dialog box.
117
+
118
+
> [!NOTE]
119
+
> To change a symbol that *is* assigned to a resource or object, you must use the resource editor or **Properties** window.
120
+
121
+
### To delete an unassigned (unused) symbol
122
+
123
+
In the [Resource Symbols dialog box](../windows/resource-symbols-dialog-box.md), select the symbol that you want to delete, and choose **Delete**.
124
+
125
+
> [!NOTE]
126
+
> 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.
127
+
128
+
## Include shared (read-only) or calculated symbols
129
+
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.
131
+
132
+
One reason you may want to use read-only symbol definitions is for symbol files that you plan to share among several projects.
133
+
134
+
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:
135
+
136
+
```cpp
137
+
#define IDC_CONTROL1 2100
138
+
#define IDC_CONTROL2 (IDC_CONTROL1+1)
139
+
```
140
+
141
+
The environment will correctly interpret these calculated symbols as long as:
142
+
143
+
- The calculated symbols are placed in a read-only symbols file.
144
+
145
+
- Your resource file contains resources to which these calculated symbols are already assigned.
146
+
147
+
- A numeric expression is expected.
148
+
149
+
> [!NOTE]
150
+
> If a string or a numeric expression is expected, then the expression is not evaluated.
151
+
152
+
### To include shared (read-only) symbols in your resource file
112
153
113
154
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.
114
155
156
+
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.
157
+
158
+
Don't call the file `Resource.h`, since that is the filename normally used by the main symbol header file.
159
+
115
160
> [!NOTE]
116
-
> 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).
161
+
> **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.
162
+
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.
164
+
165
+
1. Place the symbols in the file you specified.
166
+
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.
168
+
169
+
1. Select **OK**.
170
+
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.
117
174
118
175
1. In the **Symbol header file** box, type the new name for the include file.
0 commit comments