Answer the question
In order to leave comments, you need to log in
How to save PopupMenu items in INI?
Good day!
There is a form, on the form MainMenu with items("save form" and "load form"), Edit and Button. The Edit has a PopupMenu attached to it.
When a Button is clicked, an item is added to the PopupMenu.
procedure TfMain.ButtonClick(Sender: TObject);
var
newitem: TMenuItem;
begin
newitem:= TMenuItem.Create(TfMain.PopupMenu);
newitem.Caption:= '1';
newitem.OnClick:= ClickItem; //ClickItem - какая-то процедура
TfMain.PopupMenu.Items.Add(newitem);
end;
Ini:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'Set.ini');
//и вот тут начинается проблема...
//Ini.Write(???)('Настройки','Список пунктов',TfMain.PopupMenu.Items);
Ini.Free;
Answer the question
In order to leave comments, you need to log in
You need to manually, for each menu item, write down its properties in ini:
for i := 0 to TfMain.PopupMenu.Items.Count - 1 do begin
ini.WriteString('Настройки', 'Пункт_' + IntToStr(i) + '_Caption', TfMain.PopupMenu.Items[i].Caption);
... // и так далее, для всех остальных параметров, которые надо сохранить
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question