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 General Discussion » How to Add a menu dynamically Collapse All
Subject Author Date
yu js Oct 17, 2011 - 7:36 PM

I want to complete such function(MFC) use prof-uis 2.9.2 .How to do it
HMENU PluginsManager::SetMenu(HMENU hMenu, const char *menuName)
{
    int k=0;
    if (HasPlugin())
    {
        hPluginMenu = ::CreateMenu();
        int n = ::GetMenuItemCount(hMenu);
        for (size_t i=0; i<pluginInfos.size(); i++)
        {
            MenuItemCfg *menuItem = NULL;
            menuItem = pluginParam->SearchMenuItem(pluginInfos[i]->szDllName);
            if (menuItem)
            {
                ::InsertMenu(hMenu, n+i+1, MF_BYCOMMAND | MF_POPUP, (UINT_PTR) pluginInfos[i]->pluginMenu, menuItem->szMenuName.c_str());
                for (size_t j=0; j<pluginInfos[i]->nbMenuItems; j++)
                {
                    if (pluginInfos[i]->pMenuItems[j].PluginCmd == NULL)
                    {
                        ::InsertMenu(pluginInfos[i]->pluginMenu, j, MF_BYCOMMAND | MF_SEPARATOR, 0, TEXT(""));
                        continue;
                    }
                    menuCommands.push_back(MenuCommand(pluginInfos[i]->szDllName.c_str(), j, pluginInfos[i]->pMenuItems[j].PluginCmd));
                    int cmdID = ID_PLUGINS_CMD +(menuCommands.size()-1);
                    pluginInfos[i]->pMenuItems[j].menuID = cmdID;
                    ::InsertMenu(pluginInfos[i]->pluginMenu, j, MF_BYCOMMAND, cmdID, menuItem->szSubMenuName[k].c_str());
                    
                    if (pluginInfos[i]->pMenuItems[j]._init2Check)
                    {
                        ::CheckMenuItem(hPluginMenu, cmdID, MF_BYCOMMAND | MF_CHECKED);
                    }
                    k++;

                }
            }
        }
        return hPluginMenu;
    }
    return NULL;
}

Thanks

Technical Support Oct 24, 2011 - 7:36 AM

We do not have a sample app related to this forum thread. But, you should simply modify the command tree structure and, finally, recompute layout of toolbar’s/menu bar’s parent frame window. This can be even done automatically if you choose ProfAuto library. Please take a look at the ActiveScripts sample application. You can modify its toolbars and menus by typing script in running ActiveScripts app.

yu js Oct 20, 2011 - 12:06 AM

Sorry,I’m chinese ,I’m poor at English, i want to implement dynamic menu and toolbar. and my problem is same as http://www.prof-uis.com/prof-uis/tech-support/support-forum/noob-architectural-question-dynamically-adding-menu-items-821.aspx#@lt;/p>

where  I can find a demo


thanks

Technical Support Oct 19, 2011 - 6:27 AM