diff --git a/source/apphelpers.pas b/source/apphelpers.pas index b361f9ef..22bf64d7 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -300,6 +300,7 @@ type function DeleteFileWithUndo(sFileName: String): Boolean; function MakeInt(Str: String) : Int64; function MakeFloat(Str: String): Extended; + function RoundCommercial(e: Extended): Int64; function CleanupNumber(Str: String): String; function IsInt(Str: String): Boolean; function IsFloat(Str: String): Boolean; @@ -730,6 +731,16 @@ begin end; +function RoundCommercial(e: Extended): Int64; +begin + // "Kaufmännisch runden" + // In contrast to Delphi's Round() which rounds *.5 to the next even number + Result := Trunc(e); + if Frac(e) >= 0.5 then + Result := Result + 1; +end; + + {*** SynEdit removes all newlines and semi-randomly decides a new newline format to use for any text edited. diff --git a/source/extra_controls.pas b/source/extra_controls.pas index 8619ea8c..45e2f64e 100644 --- a/source/extra_controls.pas +++ b/source/extra_controls.pas @@ -210,7 +210,8 @@ end; } class procedure TExtForm.SaveListSetup( List: TVirtualStringTree ); var - i, ColWidth: Integer; + i: Integer; + ColWidth: Int64; ColWidths, ColsVisible, ColPos, Regname: String; OwnerForm: TWinControl; begin @@ -234,7 +235,7 @@ begin // Column widths if ColWidths <> '' then ColWidths := ColWidths + ','; - ColWidth := Round(List.Header.Columns[i].Width / OwnerForm.ScaleFactor); + ColWidth := RoundCommercial(List.Header.Columns[i].Width / OwnerForm.ScaleFactor); ColWidths := ColWidths + IntToStr(ColWidth); // Column visibility @@ -269,7 +270,8 @@ end; class procedure TExtForm.RestoreListSetup( List: TVirtualStringTree ); var i : Byte; - ColWidth, colpos : Integer; + colpos : Integer; + ColWidth: Int64; Value : String; ValueList : TStringList; Regname: String; @@ -286,7 +288,7 @@ begin for i := 0 to ValueList.Count - 1 do begin ColWidth := MakeInt(ValueList[i]); - ColWidth := Round(ColWidth * OwnerForm.ScaleFactor); + ColWidth := RoundCommercial(ColWidth * OwnerForm.ScaleFactor); // Check if column number exists and width is at least 1 pixel if (List.Header.Columns.Count > i) and (ColWidth > 0) and (ColWidth < 1000) then List.Header.Columns[i].Width := ColWidth;