I had a problem with the Combobox onchange event: In principle, if I manually select an item from combobox1, it will load / write / save the file as planned, but if I want to do the same with the loop, when I click UpdateBtn , it partially works. (The loop runs and stops at the last element, but does not create the desired file.)
I want to do if I click UpdateBtn , then Timer2 , turn on the fire (or simulate manual selection) the onChange Combobox event and create a file as it works manually.
Maybe I missed something?
Hello
Code for combobox1 (OnChange event, style: csDropDown):
procedure TForm1.ComboBox1Change(Sender: TObject); var sl : TStringList; begin if ComboBox1.ItemIndex = ComboBox1.Items.IndexOf('') then SetCurrentDir('C:\Net-AdminUpdater\') ; sl := TStringList.Create; sl.LoadFromFile('Ugloader.ini'); sl[3] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[5] := 'LASTUPGRADE='; sl[10] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[12] := 'LASTUPGRADE='; sl[17] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[19] := 'LASTUPGRADE='; sl[24] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[26] := 'LASTUPGRADE='; sl[31] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[33] := 'LASTUPGRADE='; sl[38] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; sl[40] := 'LASTUPGRADE='; sl[45] := 'AppPath=c:\users\'+ ComboBox1.Text +'\AppData\Local\Systemica'; SetCurrentDir('C:\Users\'+ ComboBox1.Text +'\WINDOWS\'); sl.SaveToFile('Ugloader.ini'); sl.LoadFromFile('Ugloader.ini'); sl.Free; end;
Timer2 (Enabled = false by default, interval 50):
ComboBox1.ItemIndex := (ComboBox1.ItemIndex + 1)
UpdateButton (UpdateBtn) (to execute the loop):
procedure TForm1.UpdateBtnClick(Sender: TObject); begin Timer2.Enabled := True;
Szabe source share