Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » using CExtPopupWnd and CExtMenuControlBar Collapse All
Subject Author Date
Pierre MEDART Jun 11, 2007 - 3:42 AM

Hi,

we have a legacy application that uses MFC CMenu and contextual menus.

We need to replace them with CExtMenuControlBar and CExtPopupWnd.

The way it works now is that we have a treecontrol, depending on the type of the node we select we populate dynamicaly a pop-up menu that we insert in our mainframe menu.

Is there a way to do that with CExtPopupWnd and CExtMenuControlBar ?

To sum up we have something like :

SetMainFrameMenu(OurObj * pObj)
{
CMenu tmp;
tmp.CreatePopupMenu();

pObj->FillPopupMenu(&tmp);

CMenu* pMenu = AfxGetApp()->GetMainWnd()->GetMenu();

pMenu->InsertMenu(nPos, MF_POPUP | MF_BYPOSITION, (UINT)tmp.Detach(), strMenuTitle);
}

What can we do ?

Technical Support Jun 11, 2007 - 6:58 AM

The following article should help you with your question:

Constructing Menus Dynamically at Run Time

Pierre MEDART Jun 11, 2007 - 9:01 AM

I’m trying to use the following code

CExtPopupMenuWnd * p_anExtPopupWnd = new CExtPopupMenuWnd;

p_anExtPopupWnd->CreatePopupMenu(GetSafeHwnd());

p_anExtPopupWnd->UpdateFromMenu(GetSafeHwnd(),&popupMenu, true, true, false);

p_anExtPopupWnd->TrackPopupMenu(0, point.x, point.y);

in this code the popupMenu is a CMenu that I populate dynamicaly.

The issue I’m facing is that the popup menu that get drawn has the size of an icon and its content is empty.

Therefore two questions:

1) can this code work ?

if no, can I populate a CExtPopupMenuWnd based on a CMenu ?

if yes, how can I display correctly the menu ?

Pierre MEDART Jun 11, 2007 - 9:37 AM

some more info

the GetItemCount on the CMenu return 7 but the GetItemCound on the CExtPopupMenuWnd return 0

Pierre MEDART Jun 11, 2007 - 10:37 AM

my fault in the

p_anExtPopupWnd->UpdateFromMenu(GetSafeHwnd(),&popupMenu, true, true, false);

I had to se the first true to false