Inserting submenus in an existing SDI menu
Posted
by Jim Johnson
on August 6th, 1998
// Add a an additional popup menu to the main menu which is
// specific to the currently selected object type. If pViewClass is NULL,
// no menu is added.
void CMainFrame::AddViewMenu(CRuntimeClass* pViewClass)
{
const int INSERT_POSITION = 3;
const int DEFAULT_MENU_COUNT = 6; // INCOMPLETE - change when test menu is
removed!
enum { PROGRAM_MENU, LAYER_MENU, KEYMAP_MENU, SAMPLE_MENU };
CMenu* pMenu = GetMenu();
ASSERT(pMenu->GetMenuItemCount() == DEFAULT_MENU_COUNT
|| pMenu->GetMenuItemCount() == DEFAULT_MENU_COUNT + 1);
// If there is already an extra menu present, remove it
if (pMenu->GetMenuItemCount() == DEFAULT_MENU_COUNT + 1)
pMenu->RemoveMenu(INSERT_POSITION, MF_BYPOSITION);
// Now based on the specific view type, add the appropriate menu
int iMenuToAdd = -1;
if (pViewClass == RUNTIME_CLASS(CProgramView))
iMenuToAdd = PROGRAM_MENU;
else if (pViewClass == RUNTIME_CLASS(CLayerView))
iMenuToAdd = LAYER_MENU;
else if (pViewClass != NULL)
ASSERT(FALSE); // INCOMPLETE - other types!
if (iMenuToAdd != -1)
{
// get the menu to add
CMenu objectMenu;
objectMenu.LoadMenu(IDR_OBJECT_MENUS);
CMenu* pPopupMenu = objectMenu.GetSubMenu(iMenuToAdd);
ASSERT(pPopupMenu != NULL);
// get its string - *^&) Windows can't figure it out for itself
CString strMenuItem;
objectMenu.GetMenuString(iMenuToAdd, strMenuItem, MF_BYPOSITION);
// Add it
VERIFY(pMenu->InsertMenu(INSERT_POSITION, MF_BYPOSITION | MF_POPUP,
(UINT)pPopupMenu->GetSafeHmenu(), strMenuItem));
// remove from the other menu!
objectMenu.RemoveMenu(iMenuToAdd, MF_BYPOSITION);
}
DrawMenuBar();
}

Comments
You pine pro some tomato basil and mozzarella. In behalf of indoor from, these slippers are as well-lighted and manueverable as sneakers.
Posted by Soaceddew on 04/20/2013 04:25amHas just released respective different color Free Inneva Woven shoes, Nike recently with another direction to lure shoes with different styling to all [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] eyes. This brings important issue Unfastened Inneva Woven is a White Call of works in the series, represents shoes Italian made the assurance. Latest Free Inneva Woven clouded and bawdy are on tap in two color schemes, to hand-knit Woven vamp in extension to infiltrated Italy's [url=http://markwarren.org.uk/property-waet.cfm]air max 90 uk[/url] finest crafts, meanwhile gives athletes close to the foot of relieve, the most superior possibility a affairs is the goal of Unused 5 configuration, barefoot feel it will allure cannot be ignored. Nike Sovereign Inneva Woven SP Pale-complexioned Id Pack on Parade 16 at outlets around the [url=http://markwarren.org.uk/property-waet.cfm]air max 90[/url] brand on the shelves, and on trade in restricted bearing, interested friends should produce results clinch notice to Nike announced the news.
ReplyDon't get messages when adding a submenu from a DLL to the main menu!
Posted by Legacy on 01/04/2002 12:00amOriginally posted by: Juergen Suetterlin
Hy folks,
I'm trying to modify my main menu out of a dynamically loaded (runtime) DLL.
My application uses loadlibrary() to load my DLL and can open it. The I call an exported function inside the DLL which adds a submenu to the main menu (procedure found also at codeguru). But when I select the added submenu all sub entries are grayed and the debuggers says this: "Warning: no message line prompt for ID 0x8015." but in the resource the item was alligned to an ID and the ID was alligned to a funciton.
Can anyone help me?
J�rgen
ReplyWorks fine now thnaks to Julien Roger's fix !!!
Posted by Legacy on 07/11/2001 12:00amOriginally posted by: Alf
In fact it works without it on Win 95 / 98 / NT systems,
Replybut crashes on Win 2000 / XP systems. With the "fix" it
works now fine !
Disable a sub menu at runtime
Posted by Legacy on 01/10/2001 12:00amOriginally posted by: Usha
I want to disable a sub menu at Runtime. Can u help me with that
Thanks
Replyusha
problem with Win95
Posted by Legacy on 08/12/1999 12:00amOriginally posted by: latha
This code works fine with NT but gives an assertion failure when i try to access the sub menu in Win95. Please let me know a solution for the same.
ReplyON_UPDATE_COMMAND_UI does not work on the inserted menu
Posted by Legacy on 03/24/1999 12:00amOriginally posted by: David Geldreich
If you try to associate an ON_UPDATE_COMMAND_UI on one of the command included in the inserted menu command routing will work but in ON_UPDATE_COMMAND_UI, pCmdUI->Enable(FALSE) will not work.
It is because things like pCmdUI->m_pMenu->EnableMenuItem(pCmdUI->m_nID, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND); will return -1.
One solution is to keep a pointer to the inserted menu and do ourself, change pCmdUI->m_pMenu before calling CCmdUI functions.
ReplyThis doesn't work
Posted by Legacy on 12/25/1998 12:00amOriginally posted by: Vasu Y
This piece of code doesn't work for me.
It is adding the new Pop-up menu to the Main menu, but if you click on the newly added pop-up menu, it is giving a Debug-Assertion Failure.
Can somebody help me out.
The following is the piece of code.
CMenu* pMainMenu = pMainFrame->GetMenu();
Replyshort iMenuToAdd;
iMenuToAdd = 0;
CMenu objectMenu;
objectMenu.LoadMenu(IDR_MENU2);
CMenu* pPopupMenu = objectMenu.GetSubMenu(iMenuToAdd);
ASSERT(pPopupMenu != NULL);
short count = 0;
count = pPopupMenu->GetMenuItemCount();
// get its string - *^&) Windows can't figure it out for itself
CString strMenuItem;
objectMenu.GetMenuString(iMenuToAdd, strMenuItem, MF_BYPOSITION);
VERIFY(pMainMenu->AppendMenu( MF_POPUP,
(UINT)pPopupMenu->Detach(), strMenuItem));
modifying SDI/MDI menus
Posted by Legacy on 10/13/1998 12:00amOriginally posted by: Brian Smith
Reply