Re: Problem with owner draw menu's and appendMenu
You may only have an HMENU at the time in the CMenuBar but you should be able to convert it to a CNewMenu like this:
Code:
CNewMenu menu;
menu.Attach(hMenu);
// use CNewMenu get menu string function
menu.Detach(); // so CMenu doesnt try and destory the menu resource
Re: Problem with owner draw menu's and appendMenu
Oh, and one other thing whilse it occurs to me.
You could modify the CNewMenu append function(s) to set the menu string in the HMENU text so GetMenuItemInfo() would return the ocrrect text.
You can do this after the regular append by making use of ModifyMenu() which you should be able to use to just set the menu item text.
Re: Problem with owner draw menu's and appendMenu
Quote:
Originally Posted by Roger Allen
You may only have an HMENU at the time in the CMenuBar but you should be able to convert it to a CNewMenu like this:
Code:
CNewMenu menu;
menu.Attach(hMenu);
// use CNewMenu get menu string function
menu.Detach(); // so CMenu doesnt try and destory the menu resource
This is what I did. I saved the old HMenu and used it with CNewMenu::GetMenuString().
Thanks alot for all your patience and help, Roger. Without that I would have stopped using guitoolkit some time ago.
So this problem is solved.
Although the next problem is that now MeasureItem functions are used. Since CNewMenu and CMenuBar are implemented with different styles, the submenus are shown, but have another style than the upper level menuitems :s. When a resource menu is loaded, the MeasureItem functions were not used it seems and all is drawn in the styles of CMenuBar - because the buttons are CGuiMenuButtons. When a menu is modified, CNewMenu::DrawItem() draws the menuitems.
Seems to be a new challenge for me to spend some time on :-(
Re: Problem with owner draw menu's and appendMenu
hi
i used Guitoolkit too,
now ,i want to dynamic create menu in CMainFrm, but i can't successed.
void CMainFrame::AddMenu()
{
CNewMenu MainMenu;
MainMenu.Attach( m_wndMenuBar.m_hMenu );
CNewMenu DllMenu ;
DllMenu.CreatePopupMenu();
DllMenu.AppendMenu(MF_POPUP|MF_OWNERDRAW,0x9498,"dddd");
DllMenu.AppendMenu(MF_POPUP|MF_OWNERDRAW,0x9397,"ddaf");
MainMenu.AppendMenu(MF_POPUP|MF_OWNERDRAW,(UINT)(DllMenu.Detach()),"Append Menu");
MainMenu.Detach();
this->DrawMenuBar();
}
i could cause assert error!
why?