Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Creating Popup on the fly but item is always disabled.

Posted on 2004-08-13
2
479 Views
Last Modified: 2013-11-20
I'm creating a popup menu on the fly and the menu item is always disabled. I've done this before without a problem, but not in a MDI Window. Do I have to do something different?

Here is what I'm doing:

// Create popup menu
CMenu PopupMenu;
PopupMenu.CreatePopupMenu();
UINT uFlags = (/*put conditional here*/true) ? MF_ENABLED : MF_GRAYED;

PopupMenu.AppendMenu( uFlags, IDS_INSERT,"Insert" );
//Tried this too
//PopupMenu.AppendMenu( MF_BYCOMMAND, IDS_INSERT,"Insert" );
//PopupMenu.EnableMenuItem( IDS_INSERT, uFlags );

// Display popup menu
CMDIFrameWnd *frameWindow = (CMDIFrameWnd*)CMDIFrameWnd::FromHandle(GetForegroundWindow());
CMDIChildWnd *voWindow    = frameWindow->MDIGetActive();
CRect rectGrid;
voWindow->GetWindowRect( rectGrid );
PopupMenu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON,
      rectGrid.left + pXY[0],
      rectGrid.bottom - pXY[1], voWindow);
0
Comment
Question by:tcf22
2 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 11795465
Do you have IDS_INSERT menu handle in the CMDIFrameWnd  class? Without menu handle item is disabled (see CFrameWnd::m_bAutoMenuEnable member). You can set this member to FALSE or add ON_UPDATE_COMMAND_UI handler and enable menu item explicitly.
0
 
LVL 3

Accepted Solution

by:
jimbucci earned 125 total points
ID: 11809852
A menu item will remain disabled until you have a handler for the menu item

add:  ON_COMMAND(ID_MENUITEM, OnMenuitem)
add:  afx_msg void OnMenuItem() to the .h file
add: void CSomeFrame::OnMenuItem() to the .cpp file.  Your menu items will appear as they are handled.

Jim
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 142
dog bark java program 15 109
sum28 challenge 31 115
ShiftLeft challenge 21 86
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question