How to using code find the menu label of Menus【X++】

// VAR Changed by Xie Yu Fan.Fandy 谢宇帆
static void XIE_FindMenu(Args _args)
{
    Dialog      dlg     = new Dialog("搜索菜单名称");
    DialogField dlgName = dlg.addField(typeId(name));
    name        menuName;

    void findMenu(SysDictMenu _sysDictMenu, name _MenuName, str _path = "" )
    {
        SysMenuEnumerator   me;
        ;
        if (_sysDictMenu.isMenuReference() || _sysDictMenu.isMenu())
        {
            _path   = (_path ? _path + "	" : _path) + _sysDictMenu.label();
            me      = _sysDictMenu.getEnumerator();
            while (me.moveNext())
            {
                findMenu(me.current(), _MenuName, _path);
            }
        }
        else
        {
            if( _sysDictMenu.label() like "*"+_MenuName+"*")
            {
                info(_path + "	" + _sysDictMenu.label());
            }
        }
    }
;
    dlg.doInit();
    dlgName.value("保存月底库存");

    if( !dlg.run())
        return;
    menuName = dlgName.value();
    if(menuName)
    {
        findMenu(SysDictMenu::newMainMenu(), menuName);
    }
}

 

原文地址:https://www.cnblogs.com/Fandyx/p/3533188.html