Skip to content

Commit 2832f1f

Browse files
authored
Merge pull request MicrosoftDocs#1759 from msebolt/resource-file-consolidation-pr52
resource file consolidation pr52
2 parents 404a882 + 01418c8 commit 2832f1f

8 files changed

Lines changed: 173 additions & 237 deletions

‎.openpublishing.redirection.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7980,6 +7980,26 @@
79807980
"redirect_url": "/cpp/windows/resource-files-visual-studio",
79817981
"redirect_document_id": false
79827982
},
7983+
{
7984+
"source_path": "docs/windows/viewing-resource-symbols.md",
7985+
"redirect_url": "/cpp/windows/creating-new-symbols",
7986+
"redirect_document_id": false
7987+
},
7988+
{
7989+
"source_path": "docs/windows/opening-the-resource-editor-for-a-given-symbol.md",
7990+
"redirect_url": "/cpp/windows/creating-new-symbols",
7991+
"redirect_document_id": false
7992+
},
7993+
{
7994+
"source_path": "docs/windows/changing-unassigned-symbols.md",
7995+
"redirect_url": "/cpp/windows/changing-a-symbol-or-symbol-name-id",
7996+
"redirect_document_id": false
7997+
},
7998+
{
7999+
"source_path": "docs/windows/including-shared-read-only-or-calculated-symbols.md",
8000+
"redirect_url": "/cpp/windows/changing-a-symbol-or-symbol-name-id",
8001+
"redirect_document_id": false
8002+
},
79838003
{
79848004
"source_path": "docs/windows/activationfactory-activationfactory-constructor.md",
79858005
"redirect_url": "/cpp/windows/activationfactory-class#activationfactory",

‎docs/windows/TOC.md‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
#### [How to: Manage Resources](how-to-copy-resources.md)
1515
#### [How to: Include Resources at Compile Time](how-to-include-resources-at-compile-time.md)
1616
### [Symbols: Resource Identifiers](symbols-resource-identifiers.md)
17-
#### [Viewing Resource Symbols](viewing-resource-symbols.md)
18-
#### [Creating New Symbols](creating-new-symbols.md)
19-
#### [Changing or Deleting Unassigned Symbols](changing-unassigned-symbols.md)
20-
#### [Opening the Resource Editor for a Given Symbol](opening-the-resource-editor-for-a-given-symbol.md)
21-
#### [Changing a Symbol](changing-a-symbol-or-symbol-name-id.md)
22-
#### [Including Shared (Read-Only) or Calculated Symbols](including-shared-read-only-or-calculated-symbols.md)
17+
#### [How to: Create Symbols](creating-new-symbols.md)
18+
#### [How to: Manage Symbols](changing-a-symbol-or-symbol-name-id.md)
2319
#### [Predefined Symbol IDs](predefined-symbol-ids.md)
2420
##### [ATL Predefined Symbols](atl-predefined-symbols.md)
2521
##### [MFC Predefined Symbols](mfc-predefined-symbols.md)
Lines changed: 97 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
---
2-
title: "Changing a Symbol"
2+
title: "How to: Manage Symbols"
33
ms.date: "11/04/2016"
4-
f1_keywords: ["vc.editors.symbol.changing", "vc.editors.symbol.restrictions.name", "vc.editors.symbol.changing.value", "vc.editors.symbol.restrictions.value", "vc.editors.symbol.changing.header"]
5-
helpviewer_keywords: ["symbol names", "symbols [C++], names", "restrictions, symbol names", "numeric values", "symbols [C++], numeric values", "numeric values, changing symbols", "symbols [C++], value restrictions", "restrictions, symbol values", "resource files [C++], multiple", "Resource Includes dialog box [C++]", "symbol header files [C++], changing names", "symbols [C++], symbol header files", "Resource.h"]
4+
f1_keywords: ["vc.editors.symbol.changing", "vc.editors.symbol.restrictions.name", "vc.editors.symbol.changing.value", "vc.editors.symbol.restrictions.value", "vc.editors.symbol.changing.header", "vc.editors.symbol.changing.unassigned", "vc.editors.symbol.shared.calculated"]
5+
helpviewer_keywords: ["symbol names", "symbols [C++], names", "restrictions, symbol names", "numeric values", "symbols [C++], numeric values", "numeric values, changing symbols", "symbols [C++], value restrictions", "restrictions, symbol values", "resource files [C++], multiple", "Resource Includes dialog box [C++]", "symbol header files [C++], changing names", "symbols [C++], symbol header files", "Resource.h", "symbols [C++], unassigned", "Change Symbol dialog box [C++]", "unassigned symbols", "symbols [C++], deleting", "symbols [C++], read-only", "symbols [C++], shared", "symbols [C++], calculated", "read-only symbols", "symbol directives", "calculated symbols", "shared symbols"]
66
ms.assetid: 26541832-8dba-4177-b642-e08f94502ea7
77
---
8-
# Changing a Symbol
8+
# How to: Manage Symbols
99

1010
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.
1111

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.
1313

1414
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.
1515

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*.
1717

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).
1920
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
3222

3323
The restrictions on symbol names are as follows:
3424

3525
- 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.
3626

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

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.
4030

41-
- Symbol names cannot contain spaces.
31+
- Symbol names can't contain spaces.
4232

43-
- 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.
4434

4535
> [!NOTE]
4636
> 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
5646
|Strings|IDS_|String in the string table|
5747
|MFC|AFX_|Reserved for predefined MFC symbols|
5848

59-
## To change a symbol value assigned to a single resource or object
49+
### To change a symbol name (ID)
6050

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

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.
6754

68-
```
69-
IDC_EDITNAME=5100
70-
```
55+
If you type a new symbol name, it's automatically assigned a value.
7156

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.
7358

74-
### Symbol value restrictions
59+
## Symbol value restrictions
7560

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

@@ -84,36 +69,108 @@ A symbol value can be any integer expressed in the normal manner for #define pre
8469

8570
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.
8671

87-
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.
8873

8974
Here are some limitations of symbol values:
9075

9176
- 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.
9277

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:
9479

9580
```cpp
9681
#define IDC_MYEDIT IDC_OTHEREDIT //not supported
9782
```
9883

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:
10085
10186
```cpp
10287
#define IDD_ABOUT ID(7) //not supported
10388
```
10489
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.
10691

10792
- 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).
10893

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

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
112153

113154
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.
114155

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+
115160
> [!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.
117174

118175
1. In the **Symbol header file** box, type the new name for the include file.
119176

@@ -123,5 +180,6 @@ Win32
123180

124181
## See also
125182

183+
[Symbols: Resource Identifiers](../windows/symbols-resource-identifiers.md)<br/>
126184
[Predefined Symbol IDs](../windows/predefined-symbol-ids.md)<br/>
127-
[Viewing Resource Symbols](../windows/viewing-resource-symbols.md)<br/>
185+
[Viewing Resource Symbols](../windows/viewing-resource-symbols.md)<br/>

‎docs/windows/changing-unassigned-symbols.md‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)