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
For local function variables, this scope transition happens when the function exits, but the scope of a frame variable can be smaller than a function if nested braces are used. This automatic deletion of frame variables is very important. In the case of simple primitive types (such as `int` or **byte**), arrays, or data structures, the automatic deletion simply reclaims the memory used by the variable. Since the variable has gone out of scope, it cannot be accessed anyway. In the case of C++ objects, however, the process of automatic deletion is a bit more complicated.
21
+
For local function variables, this scope transition happens when the function exits, but the scope of a frame variable can be smaller than a function if nested braces are used. This automatic deletion of frame variables is very important. In the case of simple primitive types (such as **int** or **byte**), arrays, or data structures, the automatic deletion simply reclaims the memory used by the variable. Since the variable has gone out of scope, it cannot be accessed anyway. In the case of C++ objects, however, the process of automatic deletion is a bit more complicated.
22
22
23
23
When an object is defined as a frame variable, its constructor is automatically invoked at the point where the definition is encountered. When the object goes out of scope, its destructor is automatically invoked before the memory for the object is reclaimed. This automatic construction and destruction can be very handy, but you must be aware of the automatic calls, especially to the destructor.
Copy file name to clipboardExpand all lines: docs/mfc/memory-management-heap-allocation.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ ms.author: "mblome"
12
12
ms.workload: ["cplusplus"]
13
13
---
14
14
# Memory Management: Heap Allocation
15
-
The heap is reserved for the memory allocation needs of the program. It is an area apart from the program code and the stack. Typical C programs use the functions `malloc` and **free** to allocate and deallocate heap memory. The Debug version of MFC provides modified versions of the C++ built-in operators **new** and **delete** to allocate and deallocate objects in heap memory.
15
+
The heap is reserved for the memory allocation needs of the program. It is an area apart from the program code and the stack. Typical C programs use the functions **malloc** and **free** to allocate and deallocate heap memory. The Debug version of MFC provides modified versions of the C++ built-in operators **new** and **delete** to allocate and deallocate objects in heap memory.
16
16
17
-
When you use **new** and **delete** instead of `malloc` and **free**, you are able to take advantage of the class library's memory-management debugging enhancements, which can be useful in detecting memory leaks. When you build your program with the Release version of MFC, the standard versions of the **new** and **delete** operators provide an efficient way to allocate and deallocate memory (the Release version of MFC does not provide modified versions of these operators).
17
+
When you use **new** and **delete** instead of **malloc** and **free**, you are able to take advantage of the class library's memory-management debugging enhancements, which can be useful in detecting memory leaks. When you build your program with the Release version of MFC, the standard versions of the **new** and **delete** operators provide an efficient way to allocate and deallocate memory (the Release version of MFC does not provide modified versions of these operators).
18
18
19
19
Note that the total size of objects allocated on the heap is limited only by your system's available virtual memory.
Copy file name to clipboardExpand all lines: docs/mfc/memory-management-resizable-memory-blocks.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.workload: ["cplusplus"]
15
15
The **new** and **delete** operators, described in the article [Memory Management: Examples](../mfc/memory-management-examples.md), are good for allocating and deallocating fixed-size memory blocks and objects. Occasionally, your application may need resizable memory blocks. You must use the standard C run-time library functions [malloc](../c-runtime-library/reference/malloc.md), [realloc](../c-runtime-library/reference/realloc.md), and [free](../c-runtime-library/reference/free.md) to manage resizable memory blocks on the heap.
16
16
17
17
> [!IMPORTANT]
18
-
> Mixing the **new** and **delete** operators with the resizable memory-allocation functions on the same memory block will result in corrupted memory in the Debug version of MFC. You should not use `realloc` on a memory block allocated with **new**. Likewise, you should not allocate a memory block with the **new** operator and delete it with **free**, or use the **delete** operator on a block of memory allocated with `malloc`.
18
+
> Mixing the **new** and **delete** operators with the resizable memory-allocation functions on the same memory block will result in corrupted memory in the Debug version of MFC. You should not use **realloc** on a memory block allocated with **new**. Likewise, you should not allocate a memory block with the **new** operator and delete it with **free**, or use the **delete** operator on a block of memory allocated with **malloc**.
Copy file name to clipboardExpand all lines: docs/mfc/menus-and-resources-container-additions.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,27 +46,27 @@ This article explains the changes that need to be made to the menus and other re
46
46
47
47
|ID|Key|Type|
48
48
|--------|---------|----------|
49
-
|**ID_CANCEL_EDIT_CNTR**|VK_ESCAPE|**VIRTKEY**|
49
+
|ID_CANCEL_EDIT_CNTR|VK_ESCAPE|**VIRTKEY**|
50
50
51
-
The second change is to create a new accelerator table that corresponds to the new menu resource created for in-place activation. This table has entries for the File and Window menus in addition to the **VK_ESCAPE** entry above. The following example is the accelerator table created for in-place activation in the MFC sample [CONTAINER](../visual-cpp-samples.md):
51
+
The second change is to create a new accelerator table that corresponds to the new menu resource created for in-place activation. This table has entries for the File and Window menus in addition to the VK_ESCAPE entry above. The following example is the accelerator table created for in-place activation in the MFC sample [CONTAINER](../visual-cpp-samples.md):
52
52
53
53
|ID|Key|Type|
54
54
|--------|---------|----------|
55
-
|`ID_FILE_NEW`|CTRL+N|**VIRTKEY**|
56
-
|`ID_FILE_OPEN`|CTRL+O|**VIRTKEY**|
57
-
|**ID_FILE_SAVE**|CTRL+S|**VIRTKEY**|
58
-
|**ID_FILE_PRINT**|CTRL+P|**VIRTKEY**|
59
-
|**ID_NEXT_PANE**|VK_F6|**VIRTKEY**|
60
-
|**ID_PREV_PANE**|SHIFT+VK_F6|**VIRTKEY**|
61
-
|**ID_CANCEL_EDIT_CNTR**|VK_ESCAPE|**VIRTKEY**|
55
+
|ID_FILE_NEW|CTRL+N|**VIRTKEY**|
56
+
|ID_FILE_OPEN|CTRL+O|**VIRTKEY**|
57
+
|ID_FILE_SAVE|CTRL+S|**VIRTKEY**|
58
+
|ID_FILE_PRINT|CTRL+P|**VIRTKEY**|
59
+
|ID_NEXT_PANE|VK_F6|**VIRTKEY**|
60
+
|ID_PREV_PANE|SHIFT+VK_F6|**VIRTKEY**|
61
+
|ID_CANCEL_EDIT_CNTR|VK_ESCAPE|**VIRTKEY**|
62
62
63
63
## <aname="_core_string_table_additions_for_container_applications"></a> String Table Additions for Container Applications
64
64
Most of the changes to string tables for container applications correspond to the additional menu items mentioned in [Container Menu Additions](#_core_container_menu_additions). They supply the text displayed in the status bar when each menu item is displayed. As an example, here are the string-table entries the application wizard generates:
65
65
66
66
|ID|String|
67
67
|--------|------------|
68
-
|**IDP_OLE_INIT_FAILED**|OLE initialization failed. Make sure that the OLE libraries are the correct version.|
69
-
|**IDP_FAILED_TO_CREATE**|Failed to create object. Make sure that the object is entered in the system registry.|
68
+
|IDP_OLE_INIT_FAILED|OLE initialization failed. Make sure that the OLE libraries are the correct version.|
69
+
|IDP_FAILED_TO_CREATE|Failed to create object. Make sure that the object is entered in the system registry.|
70
70
71
71
## See Also
72
72
[Menus and Resources (OLE)](../mfc/menus-and-resources-ole.md)
Copy file name to clipboardExpand all lines: docs/mfc/menus-and-resources-ole.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,10 +30,10 @@ This group of articles explains the use of menus and resources in MFC OLE docume
30
30
31
31
|Resource name|Use|
32
32
|-------------------|---------|
33
-
|**IDR_MAINFRAME**|Used in an MDI application if no file is open, or in an SDI application regardless of open files. This is the standard menu used in non-OLE applications.|
34
-
|**IDR_\<project>TYPE**|Used in an MDI application if files are open. Used when an application is running stand-alone. This is the standard menu used in non-OLE applications.|
35
-
|**IDR_\<project>TYPE_SRVR_IP**|Used by the server or container when an object is open in place.|
36
-
|**IDR_\<project>TYPE_SRVR_EMB**|Used by a server application if an object is opened without using in-place activation.|
33
+
|IDR_MAINFRAME|Used in an MDI application if no file is open, or in an SDI application regardless of open files. This is the standard menu used in non-OLE applications.|
34
+
|IDR_\<project>TYPE|Used in an MDI application if files are open. Used when an application is running stand-alone. This is the standard menu used in non-OLE applications.|
35
+
|IDR_\<project>TYPE_SRVR_IP|Used by the server or container when an object is open in place.|
36
+
|IDR_\<project>TYPE_SRVR_EMB|Used by a server application if an object is opened without using in-place activation.|
37
37
38
38
Each of these resource names represents a menu and, usually, an accelerator table. A similar scheme should be used in MFC applications that are not created with the application wizard.
Copy file name to clipboardExpand all lines: docs/mfc/menus-and-resources-server-additions.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,14 +41,14 @@ This article explains the changes that need to be made to the menus and other re
41
41
42
42
The second table is nearly an exact copy of the view's accelerator table. Any differences parallel changes made in the fully open menu mentioned in [Server Menu Additions](#_core_server_menu_additions).
43
43
44
-
For an example of these accelerator table changes, compare the **IDR_HIERSVRTYPE_SRVR_IP** and **IDR_HIERSVRTYPE_SRVR_EMB** accelerator tables with **IDR_MAINFRAME** in the HIERSVR.RC file included in the MFC OLE sample [HIERSVR](../visual-cpp-samples.md). The File and Window accelerators are missing from the in-place table and exact copies of them are in the embedded table.
44
+
For an example of these accelerator table changes, compare the IDR_HIERSVRTYPE_SRVR_IP and IDR_HIERSVRTYPE_SRVR_EMB accelerator tables with IDR_MAINFRAME in the HIERSVR.RC file included in the MFC OLE sample [HIERSVR](../visual-cpp-samples.md). The File and Window accelerators are missing from the in-place table and exact copies of them are in the embedded table.
45
45
46
46
## <aname="_core_string_table_additions_for_server_applications"></a> String Table Additions for Server Applications
47
47
Only one string table addition is necessary in a server application — a string to signify that the OLE initialization failed. As an example, here is the string-table entry that the application wizard generates:
48
48
49
49
|ID|String|
50
50
|--------|------------|
51
-
|**IDP_OLE_INIT_FAILED**|OLE initialization failed. Make sure that the OLE libraries are the correct version.|
51
+
|IDP_OLE_INIT_FAILED|OLE initialization failed. Make sure that the OLE libraries are the correct version.|
The same additions apply for miniservers as those listed above for full-servers. Because a miniserver cannot be run in stand-alone mode, its main menu is much smaller. The main menu created by the application wizard has only a File menu, containing only the items Exit and About. Embedded and in-place menus and accelerators for miniservers are the same as those for full-servers.
Copy file name to clipboardExpand all lines: docs/mfc/message-categories.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,17 +16,17 @@ What kinds of messages do you write handlers for There are three main categories
16
16
17
17
1. Windows messages
18
18
19
-
This includes primarily those messages beginning with the **WM_** prefix, except for **WM_COMMAND**. Windows messages are handled by windows and views. These messages often have parameters that are used in determining how to handle the message.
19
+
This includes primarily those messages beginning with the **WM_** prefix, except for WM_COMMAND. Windows messages are handled by windows and views. These messages often have parameters that are used in determining how to handle the message.
20
20
21
21
2. Control notifications
22
22
23
-
This includes **WM_COMMAND** notification messages from controls and other child windows to their parent windows. For example, an edit control sends its parent a **WM_COMMAND** message containing the **EN_CHANGE** control-notification code when the user has taken an action that may have altered text in the edit control. The window's handler for the message responds to the notification message in some appropriate way, such as retrieving the text in the control.
23
+
This includes WM_COMMAND notification messages from controls and other child windows to their parent windows. For example, an edit control sends its parent a WM_COMMAND message containing the EN_CHANGE control-notification code when the user has taken an action that may have altered text in the edit control. The window's handler for the message responds to the notification message in some appropriate way, such as retrieving the text in the control.
24
24
25
-
The framework routes control-notification messages like other **WM_** messages. One exception, however, is the **BN_CLICKED** control-notification message sent by buttons when the user clicks them. This message is treated specially as a command message and routed like other commands.
25
+
The framework routes control-notification messages like other **WM_** messages. One exception, however, is the BN_CLICKED control-notification message sent by buttons when the user clicks them. This message is treated specially as a command message and routed like other commands.
26
26
27
27
3. Command messages
28
28
29
-
This includes **WM_COMMAND** notification messages from user-interface objects: menus, toolbar buttons, and accelerator keys. The framework processes commands differently from other messages, and they can be handled by more kinds of objects, as explained in [Command Targets](../mfc/command-targets.md).
29
+
This includes WM_COMMAND notification messages from user-interface objects: menus, toolbar buttons, and accelerator keys. The framework processes commands differently from other messages, and they can be handled by more kinds of objects, as explained in [Command Targets](../mfc/command-targets.md).
30
30
31
31
## <aname="_core_windows_messages_and_control.2d.notification_messages"></a> Windows Messages and Control-Notification Messages
32
32
Messages in categories 1 and 2 — Windows messages and control notifications — are handled by windows: objects of classes derived from class `CWnd`. This includes `CFrameWnd`, `CMDIFrameWnd`, `CMDIChildWnd`, `CView`, `CDialog`, and your own classes derived from these base classes. Such objects encapsulate an `HWND`, a handle to a Windows window.
Copy file name to clipboardExpand all lines: docs/mfc/message-handling-and-command-targets.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The command dispatch interface `IOleCommandTarget` defines a simple and extensib
19
19
20
20
`IOleCommandTarget` handles the following scenarios:
21
21
22
-
- When an object is in-place activated, only the object's toolbars are typically displayed and the object's toolbars may have buttons for some of the container commands like **Print**, **Print Preview**, **Save**, `New`, **Zoom**, and others. (In-place activation standards recommend that objects remove such buttons from their toolbars, or at least disable them. This design allows those commands to be enabled and yet routed to the right handler.) Currently, there is no mechanism for the object to dispatch these commands to the container.
22
+
- When an object is in-place activated, only the object's toolbars are typically displayed and the object's toolbars may have buttons for some of the container commands like **Print**, **Print Preview**, **Save**, **New**, **Zoom**, and others. (In-place activation standards recommend that objects remove such buttons from their toolbars, or at least disable them. This design allows those commands to be enabled and yet routed to the right handler.) Currently, there is no mechanism for the object to dispatch these commands to the container.
23
23
24
24
- When an active document is embedded in an active document container (such as Office Binder), the container may need to send commands such **Print**, **Page Setup**, **Properties**, and others to the contained active document.
The `QueryStatus` method here tests whether a particular set of commands, the set being identified with a **GUID**, is supported. This call fills an array of **OLECMD** values (structures) with the supported list of commands as well as returning text describing the name of a command and/or status information. When the caller wishes to invoke a command, it can pass the command (and the set **GUID**) to **Exec** along with options and arguments, getting back a return value.
45
+
The `QueryStatus` method here tests whether a particular set of commands, the set being identified with a **GUID**, is supported. This call fills an array of **OLECMD** values (structures) with the supported list of commands as well as returning text describing the name of a command and/or status information. When the caller wishes to invoke a command, it can pass the command (and the set **GUID**) to `Exec` along with options and arguments, getting back a return value.
Copy file name to clipboardExpand all lines: docs/mfc/message-handling-and-mapping.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ This article family describes how messages and commands are processed by the MFC
16
16
17
17
In traditional programs for Windows, Windows messages are handled in a large switch statement in a window procedure. MFC instead uses [message maps](../mfc/message-categories.md) to map direct messages to distinct class member functions. Message maps are more efficient than virtual functions for this purpose, and they allow messages to be handled by the most appropriate C++ object — application, document, view, and so on. You can map a single message or a range of messages, command IDs, or control IDs.
18
18
19
-
**WM_COMMAND** messages — usually generated by menus, toolbar buttons, or accelerators — also use the message-map mechanism. MFC defines a standard [routing](../mfc/command-routing.md) of command messages among the application, frame window, view, and Active documents in your program. You can override this routing if you need to.
19
+
WM_COMMAND messages — usually generated by menus, toolbar buttons, or accelerators — also use the message-map mechanism. MFC defines a standard [routing](../mfc/command-routing.md) of command messages among the application, frame window, view, and Active documents in your program. You can override this routing if you need to.
20
20
21
21
Message maps also supply a way to update user-interface objects (such as menus and toolbar buttons), enabling or disabling them to suit the current context.
0 commit comments