|
|
|
|
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.
Subject |
Author |
Date |
|
Timothy Anderson
|
May 3, 2007 - 2:11 PM
|
|
|
Timothy Anderson
|
May 3, 2007 - 3:07 PM
|
I’m building this menu dynamically and profuis is gluing the keyboard shortcut to it inside some menu processing somewhere
... String.LoadString(IDS_MENU_PROPERTIES); pMenu->AppendMenu(MF_STRING|MF_ENABLED, ID_EDIT_PROPERTIESPXP, (LPCTSTR)String); ...
|
|
Technical Support
|
May 4, 2007 - 7:08 AM
|
If you build menus dynamically then (we guess) you handles the CExtPopupMenuWnd::g_nMsgPrepareMenu registered message handler as it is described in the How to insert menu items at run time? If so, the message handler looks as follows: LRESULT CYourDialogOrFrame::OnExtMenuPrepareLevel(WPARAM wParam, LPARAM lParam)
{
lParam;
CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
reinterpret_cast
< CExtPopupMenuWnd::MsgPrepareMenuData_t * >
( wParam );
ASSERT( pData != NULL );
CExtPopupMenuWnd * pPopup = pData->m_pPopup;
ASSERT( pPopup != NULL );
pData->m_bMenuChanged = true;
. . .
The last line of code ( pData->m_bMenuChanged = true; ) is very important to let the popup menu know that it should recompute its size and layout. If you construct y popup menus in some other way, please provide us with more info.
|
|
Timothy Anderson
|
May 4, 2007 - 1:33 PM
|
I’m building a popup. I blocked out a set of menu id’s that I change dynamically according to what tree node I’m currently on. I ask each node to return a CMenu that has a variable number of these menu id’s along with a block of custom text. like this (stripped down a little):
// we are inside OnRClick here // do floating menu based off of the individual node we are on CMenu MainFloatMenu; pNode->GetRClickMenu(&MainFloatMenu);
// We now have a MainFloatMenu with custom strings inside my blocked out menu id range, // along with the usual cut/copy/past/properties stuff
//Message handled! *pResult = 1;
// USE_PROFUIS_TOOLKIT // These things are deleted "magically" by the profuis toolkit CExtPopupMenuWnd *pPopupMenu = new CExtPopupMenuWnd;
// Here’s the problem // If I do this call it sets up the spacing correctly BUT it also changes // my customized menu strings back to the original ones as blocked out in // a spare menu inside of my resources pPopupMenu->UpdateFromMenu(GetSafeHwnd(), &MainFloatMenu, false, true, false);
// However, if I do this it leaves the customized menus alone but does incorrect spacing // of the properties menu item pPopupMenu->UpdateFromMenu(GetSafeHwnd(), &MainFloatMenu, false, true, true);
pPopupMenu->TrackPopupMenu ...
I also never get the afore mentioned custom menu handler message inside cmainframe (it’s an mdi app). I’m apparently doing something wrong with this way of doing things?
|
|
Technical Support
|
May 5, 2007 - 4:55 AM
|
We traced the CExtPopupMenuWnd::UpdateFromMenu() , CExtPopupMenuWnd::MENUITEMDATA::UpdateFromMenu() and CExtPopupMenuWnd::_SyncItems() methods and found nothing wrong with them: a sub menu level is measured OK regardless of whether it’s based on the command manager or not (the fourth parameter in UpdateFromMenu() ). We suspect there must be something specific in scope of your project and it may have to do with the item icon only. Could you create a small dialog-based test project which contains one control and the code which displays context menu over this control exactly like in your project?
|
|