@@ -368,7 +368,7 @@ TAppSettings = class(TObject)
368368 procedure StreamToClipboard (Text, HTML: TStream);
369369 function WideHexToBin (text: String): AnsiString;
370370 function BinToWideHex (bin: AnsiString): String;
371- procedure FixVT (VT: TVirtualStringTree; MultiLineCount: Word= 1 );
371+ procedure FixVT (VT: TVirtualStringTree; IsResultGrid: Boolean=False );
372372 function GetTextHeight (Font: TFont): Integer;
373373 function ColorAdjustBrightness (Col: TColor; Shift: SmallInt): TColor;
374374 procedure DeInitializeVTNodes (Sender: TBaseVirtualTree);
@@ -1455,19 +1455,22 @@ procedure StreamToClipboard(Text, HTML: TStream);
14551455end ;
14561456
14571457
1458- procedure FixVT (VT: TVirtualStringTree; MultiLineCount: Word= 1 );
1458+ procedure FixVT (VT: TVirtualStringTree; IsResultGrid: Boolean=False );
14591459var
1460- SingleLineHeight: Integer;
1460+ SingleLineHeight, MultiLineCount : Integer;
14611461 Node: PVirtualNode;
14621462begin
1463- // This is called either in some early stage, or from preferences dialog
1463+ // This is called either in some early stage (and probably from preferences/apply button?)
14641464 SingleLineHeight := GetTextHeight(VT.Font) + 7 ;
14651465 // Multiline nodes?
1466- // Node height calculation has some hard to find bug, see issue #2344
1467- // So we'll leave Header.MinHeight at its default value.
1466+ if IsResultGrid then
1467+ MultiLineCount := AppSettings.ReadInt(asGridRowLineCount)
1468+ else
1469+ MultiLineCount := 1 ;
1470+ // Issue #2344: TBaseVirtualTree.UpdateVerticalRange crashes with ERangeError, due to FRangeY/Cardinal
1471+ // getting a negative value
1472+ // Happening when DefaultNodeHeight is set after clearing nodes and then with 0 nodes
14681473 VT.DefaultNodeHeight := SingleLineHeight * MultiLineCount;
1469- // VT.Header.MinHeight := SingleLineHeight;
1470- VT.Header.Height := SingleLineHeight;
14711474 if MultiLineCount > 1 then begin
14721475 VT.BeginUpdate;
14731476 Node := VT.GetFirstInitialized;
@@ -1488,21 +1491,33 @@ procedure FixVT(VT: TVirtualStringTree; MultiLineCount: Word=1);
14881491 VT.OnMouseWheel := MainForm.AnyGridMouseWheel;
14891492 VT.ShowHint := True;
14901493
1491- if toGridExtensions in VT.TreeOptions.MiscOptions then
1492- VT.HintMode := hmHint // Show cell contents with linebreakds in datagrid and querygrid's
1494+ if IsResultGrid then begin
1495+ VT.HintMode := hmHint; // Show cell contents with linebreakds in datagrid and querygrid's
1496+ if AppSettings.ReadBool(asIncrementalSearch) then begin
1497+ // Apply case insensitive incremental search event
1498+ VT.IncrementalSearch := isInitializedOnly;
1499+ VT.OnIncrementalSearch := Mainform.AnyGridIncrementalSearch;
1500+ end
1501+ else begin
1502+ VT.IncrementalSearch := isNone;
1503+ end ;
1504+ end
14931505 else
14941506 VT.HintMode := hmTooltip; // Just a quick tooltip for clipped nodes
1495- // Apply case insensitive incremental search event
1496- if VT.IncrementalSearch <> laz.VirtualTrees.isNone then
1497- VT.OnIncrementalSearch := Mainform.AnyGridIncrementalSearch;
14981507 VT.OnStartOperation := Mainform.AnyGridStartOperation;
14991508 VT.OnEndOperation := Mainform.AnyGridEndOperation;
15001509end ;
15011510
15021511
15031512function GetTextHeight (Font: TFont): Integer;
1513+ var
1514+ Bmp: Graphics.TBitmap;
15041515begin
1505- Result := MainForm.Canvas.TextHeight(' Äy' );
1516+ Bmp := Graphics.TBitmap.Create;
1517+ Bmp.Canvas.Font.Name := Font.Name ;
1518+ Bmp.Canvas.Font.Size := Font.Size;
1519+ Result := Bmp.Canvas.TextHeight(' Äy' );
1520+ Bmp.Free;
15061521end ;
15071522
15081523
0 commit comments