I confirm : they are all the properties which are copied out moved there and this is due to a bad synchronistation of saving and restitition of the parameters of an account during the change of selection. I recommend by waiting to move the account to be deleted at the end of list before erasing it
procedure ToptionsFrm.deleteAccount(i:integer=-1);
begin
if i < 0 then
begin
i:=accountsBox.itemIndex;
if i < 0 then exit;
if msgDlg('Delete?', MB_ICONQUESTION+MB_YESNO) = IDNO then
exit;
end;
// shift
for i:=i+1 to length(tempAccounts)-1 do
tempAccounts[i-1]:=tempAccounts[ i ];
// shorten
i:=length(tempAccounts)-1;
setlength(tempAccounts, i);
i:=accountsBox.itemIndex; //this correct one minnor display bug
accountsBox.items.delete(0);
accountsBox.items.delete(i);
accountsbox.itemIndex:=min(i,accountsbox.items.Count-1);
loadAccountProperties(); //add by mars
accountsBox.invalidate();
end; // deleteAccount
A small visual inconvenience: when we add an account new, the parameters of the former are still visible at the time of reappointing this account new, the girl modif below avoids it
procedure ToptionsFrm.addaccountBtnClick(Sender: TObject);
var
i: integer;
a: Taccount;
begin
a.user:=getUniqueName('new user', userExists);
a.pwd:='';
a.enabled:=TRUE;
a.noLimits:=FALSE;
a.redir:='';
i:=length(tempAccounts);
setLength(tempAccounts, i+1);
tempAccounts[ i ]:=a;
accountsBox.count:=i+1;
accountsBox.ItemIndex:=i;
loadAccountProperties(); //add by mars
renaccountBtnClick(sender);
end;
Small personal addition:
DoubleClick on an account to rename it,
procedure ToptionsFrm.accountsBoxDblClick(Sender: TObject);
begin
renaccountBtn.Click();
end;
The touch INS allows to add an account ,
Reminder: the arrows UP an DOWN allow to change the accounts selection,
Addition of the touch ALT+UP/DOWN to move an account in the list.
procedure ToptionsFrm.accountsBoxKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if inPlaceEditBox.Visible then exit;
if shift = [] then
case key of
VK_F2: renaccountBtn.click();
VK_DELETE: deleteAccount();
VK_INSERT: addaccountBtn.Click();
end;
if shift = [ssAlt] then
case key of
VK_UP: upBtn.click();
VK_DOWN: downBtn.Click();
end;
end;
another visual bug corrected by add
procedure ToptionsFrm.accountsBoxMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if accountsBox.ItemAtPos(point(x,y), TRUE) < 0 then
accountsbox.itemindex:=accountsbox.count-1;
end;