Solved

Creating Popup on the fly but item is always disabled.

Posted on 2004-08-13
2
480 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
[X]
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
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 95
VBA "SendKeys" Syntax for Multiple Keystrokes 7 126
canBalance challenge 34 105
Work with App store 7 96
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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