Article ID: 141199 - Last Review: December 1, 2003 - Revision: 2.0 FIX: Pop-Up Menu Items Disabled for an OLE ControlThis article was previously published under Q141199 On This PageSYMPTOMS
The menu items are disabled even though menu handlers were added with
Class Wizard when you create an OLE Control and then use the Pop-up Menu
component in the Component Gallery to add a context menu to the COleControl
derived class. The problem occurs after you modify the context menu, and
then add handlers for the menu items, build the Control, place it in
Tstcon32.exe, and bring up the context menu.
CAUSE
Within the OnContextMenu function added by the Pop-up Menu Component, the
code makes the top-most parent window the parent of the context menu. The
menu sends the WM_COMMAND message to its parent first, which can then route
the command appropriately through the application. This method works for
windows in an MFC application that are part of the command-routing scheme.
However, because OLE Controls are not part of the routing mechanism, the
WM_COMMAND message never gets back to them and therefore the context menu
doesn't see the handlers, so the menu items are disabled.
RESOLUTION
When you add a context menu to an OLE control, you need to make the
COleControl derived class the parent of the context menu. The Pop-up Menu
Component creates the following code within the CWnd derived class. If the
pop-up menu is being added to a COleControl-derived class, you need to
delete the following lines of code:
Code Created by Pop-up Menu ComponentSTATUS
This problem was corrected in Visual C++ version 6.0 for Windows.
APPLIES TO
| Article Translations
|

Back to the top
