mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Fix too narrow column widths restored with high DPI setting, due to Delphi's Round() function using the nearest *even* number. Use the better suited "kaufmännisch runden" approach.
This commit is contained in:
@@ -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<66>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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user