Dynamic menu items / Динамические пункты меню - Forum

Forum Navigation
You need to log in to create posts and topics.

Dynamic menu items / Динамические пункты меню

У меня есть такая особенность,  в любой программе я создаю отдельную папку для языков мира.
Для каждого языка создается отдельный файл *.ini , в файле настроек программы хранится выбранный язык.
В самой программе я создаю пункт в меню (язык/lang) , программа перебирает языковые файлы в папке и добавляет их названия в  меню..
Как получить имена файлов я понимаю, но у меня возникла проблема с динамическим созданием пунктов меню, я не могу понять как их создать и как каждому пункту добавить действие на клик.

I have such a feature, in any program I create a separate folder for the languages of the world.
A separate *.ini file is created for each language, the selected language is stored in the program settings file.
In the program itself, I create an item in the menu (язык/ lang) , the program goes through the language files and adds their names to the menu ..
I understand how to get the file names, but I have a problem with the dynamic creation of menu items, I can’t figure out how to create them and how to add an action on click to each item.

Hi, @lolo

As far as I know menu items are created only at design time, but an idea could be do this manually (it could take time). Create all menu items for every .ini file, on Startup event you can check if that ini file exist and if not exist, you can hide the MenuItem for that language.

Something like this:

FileExists "[PubDir]AnyFolder\English-Lang.ini" "[exist]"
If "[exist]" "=" "False"
HideMenuItem "MenuItem1"
EndIf

Regards.

@asleycruz

this is the problem, the file name is not known in advance.
any user can create their own language file

в этом и проблема, имя файла заранее не известно.
любой пользователь может создать свой языковой файл

@lolo

If the name of the file is not known, you can let the user select it and write the file name to a variable.

Asley suggested a working variant. You can prepare several menu items in advance and immediately put the necessary code on them, but hide and show only when necessary, as a header menu can also use a variable.

And for dynamic creation of the menu you can try plugin asMenuBar https://visualneo.com/product/asmenubar

@vadim

MenuBar is not suitable, it creates a panel with a set of buttons and I need to control the system menu.
In any case, thanks for the advice.
I decided to use a drop down list.

MenuBar не подходит , он создает панель с набором кнопок а мне нужно управление системным меню .
В любом случае спасибо за совет.
Я решил использовать выпадающий список.