BUG: MFC OLE Container Support May Merge Server Menus Incorrectly (259404)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q259404 SYMPTOMS
Microsoft Foundation Class Library (MFC) Active Document Container programs may improperly merge server menus when in-place activating an Active Document object. Top-level menu items may not appear in the expected order.
CAUSE
Some Active Document Servers (such as Microsoft Excel) do not always pass a zero-initialized array of OLEMENUGROUPWIDTHS to the container's IOleInPlaceFrame::SetMenus function. The way in which MFC implements IOleInPlaceFrame::SetMenus makes use of the AfxMergeMenus function, which is used by both MFC containers and servers. When the OLEMENUGROUPWIDTHS array contains non-zeros, the AfxMergeMenus call runs the server code path instead of the code path for containers, which causes the menus to be merged in the wrong order.
RESOLUTION
To work around this problem, override the container's COleDocObjectItem-derived class's OnInsertMenus function, initialize the OLEMENUGROUPWIDTHS structure with zeros, and then call the base COleDocObjectItem::OnInsertMenus. For example:
void CTestAppCntrItem::OnInsertMenus(CMenu* pMenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
memset(lpMenuWidths,0,sizeof(OLEMENUGROUPWIDTHS));
COleDocObjectItem::OnInsertMenus(pMenuShared,lpMenuWidths);
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCES
Chapter 22, Inside OLE 2nd Edition. Kraig Brockschmidt, Microsoft Press.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbBug kbContainer kbnofix KB259404 |
---|
|