Skip to content

Commit c7c037a

Browse files
author
Colin Robertson
authored
Merge pull request #1379 from corob-msft/cr-frontier-mfc
Fix Markdig issues in MFC
2 parents d296fb2 + 4411cb1 commit c7c037a

File tree

1,284 files changed

+238370
-209694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,284 files changed

+238370
-209694
lines changed

docs/mfc/a-portrait-of-the-document-view-architecture.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,30 @@ ms.author: "mblome"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# A Portrait of the Document/View Architecture
15-
Documents and views are paired in a typical MFC application. Data is stored in the document, but the view has privileged access to the data. The separation of document from view separates the storage and maintenance of data from its display.
16-
17-
## Gaining Access to Document Data from the View
18-
The view accesses its document's data either with the [GetDocument](../mfc/reference/cview-class.md#getdocument) function, which returns a pointer to the document, or by making the view class a C++ `friend` of the document class. The view then uses its access to the data to obtain the data when it is ready to draw or otherwise manipulate it.
19-
20-
For example, from the view's [OnDraw](../mfc/reference/cview-class.md#ondraw) member function, the view uses `GetDocument` to obtain a document pointer. Then it uses that pointer to access a `CString` data member in the document. The view passes the string to the `TextOut` function. To see the code for this example, see [Drawing in a View](../mfc/drawing-in-a-view.md).
21-
22-
## User Input to the View
23-
The view might also interpret a mouse click within itself as either selection or editing of data. Similarly it might interpret keystrokes as data entry or editing. Suppose the user types a string in a view that manages text. The view obtains a pointer to the document and uses the pointer to pass the new data to the document, which stores it in some data structure.
24-
25-
## Updating Multiple Views of the Same Document
26-
In an application with multiple views of the same document — such as a splitter window in a text editor — the view first passes the new data to the document. Then it calls the document's [UpdateAllViews](../mfc/reference/cdocument-class.md#updateallviews) member function, which tells all views of the document to update themselves, reflecting the new data. This synchronizes the views.
27-
28-
### What do you want to know more about
29-
30-
- [Advantages of the document/view architecture](../mfc/advantages-of-the-document-view-architecture.md)
31-
32-
- [Alternatives to the document/view architecture](../mfc/alternatives-to-the-document-view-architecture.md)
33-
34-
## See Also
35-
[Document/View Architecture](../mfc/document-view-architecture.md)
15+
16+
Documents and views are paired in a typical MFC application. Data is stored in the document, but the view has privileged access to the data. The separation of document from view separates the storage and maintenance of data from its display.
17+
18+
## Gaining Access to Document Data from the View
19+
20+
The view accesses its document's data either with the [GetDocument](../mfc/reference/cview-class.md#getdocument) function, which returns a pointer to the document, or by making the view class a C++ `friend` of the document class. The view then uses its access to the data to obtain the data when it is ready to draw or otherwise manipulate it.
21+
22+
For example, from the view's [OnDraw](../mfc/reference/cview-class.md#ondraw) member function, the view uses `GetDocument` to obtain a document pointer. Then it uses that pointer to access a `CString` data member in the document. The view passes the string to the `TextOut` function. To see the code for this example, see [Drawing in a View](../mfc/drawing-in-a-view.md).
23+
24+
## User Input to the View
25+
26+
The view might also interpret a mouse click within itself as either selection or editing of data. Similarly it might interpret keystrokes as data entry or editing. Suppose the user types a string in a view that manages text. The view obtains a pointer to the document and uses the pointer to pass the new data to the document, which stores it in some data structure.
27+
28+
## Updating Multiple Views of the Same Document
29+
30+
In an application with multiple views of the same document — such as a splitter window in a text editor — the view first passes the new data to the document. Then it calls the document's [UpdateAllViews](../mfc/reference/cdocument-class.md#updateallviews) member function, which tells all views of the document to update themselves, reflecting the new data. This synchronizes the views.
31+
32+
### What do you want to know more about
33+
34+
- [Advantages of the document/view architecture](../mfc/advantages-of-the-document-view-architecture.md)
35+
36+
- [Alternatives to the document/view architecture](../mfc/alternatives-to-the-document-view-architecture.md)
37+
38+
## See Also
39+
40+
[Document/View Architecture](../mfc/document-view-architecture.md)
3641

docs/mfc/accessing-all-members-of-a-collection.md

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,57 @@ ms.author: "mblome"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# Accessing All Members of a Collection
15-
The MFC array collection classes — both template-based and not — use indexes to access their elements. The MFC list and map collection classes — both template-based and not — use an indicator of type **POSITION** to describe a given position within the collection. To access one or more members of these collections, you first initialize the position indicator and then repeatedly pass that position to the collection and ask it to return the next element. The collection is not responsible for maintaining state information about the progress of the iteration. That information is kept in the position indicator. But, given a particular position, the collection is responsible for returning the next element.
16-
17-
The following procedures show how to iterate over the three main types of collections provided with MFC:
18-
19-
- [Iterating an array](#_core_to_iterate_an_array)
20-
21-
- [Iterating a list](#_core_to_iterate_a_list)
22-
23-
- [Iterating a map](#_core_to_iterate_a_map)
24-
25-
### <a name="_core_to_iterate_an_array"></a> To iterate an array
26-
27-
1. Use sequential index numbers with the `GetAt` member function:
28-
29-
[!code-cpp[NVC_MFCCollections#12](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_1.cpp)]
30-
31-
This example uses a typed pointer array that contains pointers to `CPerson` objects. The array is derived from class `CObArray`, one of the nontemplate predefined classes. `GetAt` returns a pointer to a `CPerson` object. For typed pointer collection classes — arrays or lists — the first parameter specifies the base class; the second parameter specifies the type to store.
32-
33-
The `CTypedPtrArray` class also overloads the **[ ]** operator so that you can use the customary array-subscript syntax to access elements of an array. An alternative to the statement in the body of the **for** loop above is
34-
35-
[!code-cpp[NVC_MFCCollections#13](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_2.cpp)]
36-
37-
This operator exists in both **const** and non-**const** versions. The **const** version, which is invoked for **const** arrays, can appear only on the right side of an assignment statement.
38-
39-
### <a name="_core_to_iterate_a_list"></a> To iterate a list
40-
41-
1. Use the member functions `GetHeadPosition` and `GetNext` to work your way through the list:
42-
43-
[!code-cpp[NVC_MFCCollections#14](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_3.cpp)]
44-
45-
This example uses a typed pointer list to contain pointers to `CPerson` objects. The list declaration resembles the one for the array in the procedure [To iterate an array](#_core_to_iterate_an_array) but is derived from class `CObList`. `GetNext` returns a pointer to a `CPerson` object.
46-
47-
### <a name="_core_to_iterate_a_map"></a> To iterate a map
48-
49-
1. Use `GetStartPosition` to get to the beginning of the map and `GetNextAssoc` to repeatedly get the next key and value from the map, as shown by the following example:
50-
51-
[!code-cpp[NVC_MFCCollections#15](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_4.cpp)]
52-
53-
This example uses a simple map template (rather than a typed pointer collection) that uses `CString` keys and stores pointers to `CPerson` objects. When you use access functions such as `GetNextAssoc`, the class provides pointers to `CPerson` objects. If you use one of the nontemplate map collections instead, you must cast the returned `CObject` pointer to a pointer to a `CPerson`.
54-
15+
16+
The MFC array collection classes — both template-based and not — use indexes to access their elements. The MFC list and map collection classes — both template-based and not — use an indicator of type **POSITION** to describe a given position within the collection. To access one or more members of these collections, you first initialize the position indicator and then repeatedly pass that position to the collection and ask it to return the next element. The collection is not responsible for maintaining state information about the progress of the iteration. That information is kept in the position indicator. But, given a particular position, the collection is responsible for returning the next element.
17+
18+
The following procedures show how to iterate over the three main types of collections provided with MFC:
19+
20+
- [Iterating an array](#_core_to_iterate_an_array)
21+
22+
- [Iterating a list](#_core_to_iterate_a_list)
23+
24+
- [Iterating a map](#_core_to_iterate_a_map)
25+
26+
### <a name="_core_to_iterate_an_array"></a> To iterate an array
27+
28+
1. Use sequential index numbers with the `GetAt` member function:
29+
30+
[!code-cpp[NVC_MFCCollections#12](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_1.cpp)]
31+
32+
This example uses a typed pointer array that contains pointers to `CPerson` objects. The array is derived from class `CObArray`, one of the nontemplate predefined classes. `GetAt` returns a pointer to a `CPerson` object. For typed pointer collection classes — arrays or lists — the first parameter specifies the base class; the second parameter specifies the type to store.
33+
34+
The `CTypedPtrArray` class also overloads the **[ ]** operator so that you can use the customary array-subscript syntax to access elements of an array. An alternative to the statement in the body of the **for** loop above is
35+
36+
[!code-cpp[NVC_MFCCollections#13](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_2.cpp)]
37+
38+
This operator exists in both **const** and non-**const** versions. The **const** version, which is invoked for **const** arrays, can appear only on the right side of an assignment statement.
39+
40+
### <a name="_core_to_iterate_a_list"></a> To iterate a list
41+
42+
1. Use the member functions `GetHeadPosition` and `GetNext` to work your way through the list:
43+
44+
[!code-cpp[NVC_MFCCollections#14](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_3.cpp)]
45+
46+
This example uses a typed pointer list to contain pointers to `CPerson` objects. The list declaration resembles the one for the array in the procedure [To iterate an array](#_core_to_iterate_an_array) but is derived from class `CObList`. `GetNext` returns a pointer to a `CPerson` object.
47+
48+
### <a name="_core_to_iterate_a_map"></a> To iterate a map
49+
50+
1. Use `GetStartPosition` to get to the beginning of the map and `GetNextAssoc` to repeatedly get the next key and value from the map, as shown by the following example:
51+
52+
[!code-cpp[NVC_MFCCollections#15](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_4.cpp)]
53+
54+
This example uses a simple map template (rather than a typed pointer collection) that uses `CString` keys and stores pointers to `CPerson` objects. When you use access functions such as `GetNextAssoc`, the class provides pointers to `CPerson` objects. If you use one of the nontemplate map collections instead, you must cast the returned `CObject` pointer to a pointer to a `CPerson`.
55+
5556
> [!NOTE]
56-
> For nontemplate maps, the compiler requires a reference to a `CObject` pointer in the last parameter to `GetNextAssoc`. On input, you must cast your pointers to that type, as shown in the next example.
57-
58-
The template solution is simpler and helps provide better type safety. The nontemplate code is more complicated, as you can see here:
59-
60-
[!code-cpp[NVC_MFCCollections#16](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_5.cpp)]
61-
62-
For more information, see [Deleting All Objects in a CObject Collection](../mfc/deleting-all-objects-in-a-cobject-collection.md).
63-
64-
## See Also
65-
[Collections](../mfc/collections.md)
57+
> For nontemplate maps, the compiler requires a reference to a `CObject` pointer in the last parameter to `GetNextAssoc`. On input, you must cast your pointers to that type, as shown in the next example.
58+
59+
The template solution is simpler and helps provide better type safety. The nontemplate code is more complicated, as you can see here:
60+
61+
[!code-cpp[NVC_MFCCollections#16](../mfc/codesnippet/cpp/accessing-all-members-of-a-collection_5.cpp)]
62+
63+
For more information, see [Deleting All Objects in a CObject Collection](../mfc/deleting-all-objects-in-a-cobject-collection.md).
64+
65+
## See Also
66+
67+
[Collections](../mfc/collections.md)
6668

docs/mfc/accessing-file-status.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ ms.author: "mblome"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# Accessing File Status
15-
`CFile` also supports getting file status, including whether the file exists, creation and modification dates and times, logical size, and path.
16-
17-
### To get file status
18-
19-
1. Use the [CFile](../mfc/reference/cfile-class.md) class to get and set information about a file. One useful application is to use the `CFile` static member function **GetStatus** to determine if a file exists. **GetStatus** returns 0 if the specified file does not exist.
20-
21-
Thus, you could use the result of **GetStatus** to determine whether to use the **CFile::modeCreate** flag when opening a file, as shown by the following example:
22-
23-
[!code-cpp[NVC_MFCFiles#3](../atl-mfc-shared/reference/codesnippet/cpp/accessing-file-status_1.cpp)]
24-
25-
For related information, see [Serialization](../mfc/serialization-in-mfc.md).
26-
27-
## See Also
28-
[Files](../mfc/files-in-mfc.md)
15+
16+
`CFile` also supports getting file status, including whether the file exists, creation and modification dates and times, logical size, and path.
17+
18+
### To get file status
19+
20+
1. Use the [CFile](../mfc/reference/cfile-class.md) class to get and set information about a file. One useful application is to use the `CFile` static member function **GetStatus** to determine if a file exists. **GetStatus** returns 0 if the specified file does not exist.
21+
22+
Thus, you could use the result of **GetStatus** to determine whether to use the **CFile::modeCreate** flag when opening a file, as shown by the following example:
23+
24+
[!code-cpp[NVC_MFCFiles#3](../atl-mfc-shared/reference/codesnippet/cpp/accessing-file-status_1.cpp)]
25+
26+
For related information, see [Serialization](../mfc/serialization-in-mfc.md).
27+
28+
## See Also
29+
30+
[Files](../mfc/files-in-mfc.md)
2931

0 commit comments

Comments
 (0)