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
Copy file name to clipboardExpand all lines: docs/mfc/tn041-mfc-ole1-migration-to-mfc-ole-2.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "TN041: MFC-OLE1 Migration to MFC-OLE 2 | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "06/28/2018"
4
+
ms.date: "10/18/2018"
5
5
ms.technology: ["cpp-mfc"]
6
6
ms.topic: "conceptual"
7
7
f1_keywords: ["vc.mfc.ole"]
@@ -283,7 +283,7 @@ At this point, OCLIENT is a functional OLE container application. It is possible
283
283
284
284
One of the most interesting features of OLE is in-place activation (or "Visual Editing"). This feature allows the server application to take over portions of the container's user interface to provided a more seamless editing interface for the user. To implement in-place activation to OCLIENT, some special resources need to be added, as well as some additional code. These resources and the code are normally provided by AppWizard — in fact, much of the code here was borrowed directly from a fresh AppWizard application with "Container" support.
285
285
286
-
First of all, it is necessary to add a menu resource to be used when there is an item which is in-place active. You can create this extra menu resource in Visual C++ by copying the IDR_OCLITYPE resource and removing all but the File and Window pop-ups. Two separator bars are inserted between the File and Window pop-ups to indicate the separation of groups (it should look like: File || Window). For more information on what these separators mean and how the server and container menus are merged see "Menus and Resources: Menu Merging" in *OLE 2 Classes*.
286
+
First of all, it is necessary to add a menu resource to be used when there is an item which is in-place active. You can create this extra menu resource in Visual C++ by copying the IDR_OCLITYPE resource and removing all but the File and Window pop-ups. Two separator bars are inserted between the File and Window pop-ups to indicate the separation of groups (it should look like: File || Window). For more information on what these separators mean and how the server and container menus are merged see [Menus and Resources: Menu Merging](../mfc/menus-and-resources-menu-merging.md).
287
287
288
288
Once you have these menus created, you need to let the framework know about them. This is done by calling `CDocTemplate::SetContainerInfo` for the document template before you add it to the document template list in your InitInstance. The new code to register the document template looks like this:
289
289
@@ -600,7 +600,7 @@ There are many more errors in svritem.cpp that have not been addressed. They are
600
600
\hiersvr\svrview.cpp(325) : error C2660: 'CopyToClipboard' : function does not take 2 parameters
601
601
```
602
602
603
-
`COleServerItem::CopyToClipboard` no longer supports the 'bIncludeNative' flag. The native data (the data written out by the server item's Serialize function) is always copied, so you remove the first parameter. In addition, `CopyToClipboard` will throw an exception when an error happens instead of returning FALSE. Change the code for CServerView::OnEditCopy as follows:
603
+
`COleServerItem::CopyToClipboard` no longer supports the `bIncludeNative` flag. The native data (the data written out by the server item's Serialize function) is always copied, so you remove the first parameter. In addition, `CopyToClipboard` will throw an exception when an error happens instead of returning FALSE. Change the code for CServerView::OnEditCopy as follows:
604
604
605
605
```cpp
606
606
voidCServerView::OnEditCopy()
@@ -636,7 +636,7 @@ To add "Visual Editing" (or in-place activation) to this server application, the
636
636
637
637
- You need to tell the framework about these special resources and classes.
638
638
639
-
The menu resource is easy to create. Run Visual C++, copy the menu resource IDR_HIERSVRTYPE to a menu resource called IDR_HIERSVRTYPE_SRVR_IP. Modify the menu so that only the Edit and Help menu popups are left. Add two separators to the menu in between the Edit and Help menus (it should look like: Edit || Help). For more information on what these separators mean and how the server and container menus are merged, see "Menus and Resources: Menu Merging" in *OLE 2 Classes*.
639
+
The menu resource is easy to create. Run Visual C++, copy the menu resource IDR_HIERSVRTYPE to a menu resource called IDR_HIERSVRTYPE_SRVR_IP. Modify the menu so that only the Edit and Help menu popups are left. Add two separators to the menu in between the Edit and Help menus (it should look like: Edit || Help). For more information on what these separators mean and how the server and container menus are merged, see [Menus and Resources: Menu Merging](../mfc/menus-and-resources-menu-merging.md).
640
640
641
641
The bitmap for the subset toolbar can be easily created by copying the one from a fresh AppWizard generated application with a "Server" option checked. This bitmap can then be imported into Visual C++. Be sure to give the bitmap an ID of IDR_HIERSVRTYPE_SRVR_IP.
Notice the reference to *`AfxGetApp()->m_pMainWnd*`. When the server is in-place activated, it has a main window and m_pMainWnd is set, but it is usually invisible. Furthermore, this window refers to the *main* window of the application, the MDI frame window that appears when the server is fully open or run stand-alone. It does not refer to the active frame window — which when in-place activated is a frame window derived from `COleIPFrameWnd`. To get the correct active window even when in-place editing, this version of MFC adds a new function, `AfxGetMainWnd`. Generally, you should use this function instead of *`AfxGetApp()->m_pMainWnd*`. This code needs to change as follows:
662
+
Notice the reference to `AfxGetApp()->m_pMainWnd`. When the server is in-place activated, it has a main window and m_pMainWnd is set, but it is usually invisible. Furthermore, this window refers to the *main* window of the application, the MDI frame window that appears when the server is fully open or run stand-alone. It does not refer to the active frame window — which when in-place activated is a frame window derived from `COleIPFrameWnd`. To get the correct active window even when in-place editing, this version of MFC adds a new function, `AfxGetMainWnd`. Generally, you should use this function instead of `AfxGetApp()->m_pMainWnd`. This code needs to change as follows:
0 commit comments