From c3b2debdbdc6837487c8e402f43e46b60ad51eb6 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 7 May 2011 05:38:20 +0000 Subject: [PATCH] Disable tooltips in any Virtual Tree instance if running on Wine, as they prevent clicks on clipped nodes. Fixes issue #2404. --- source/main.pas | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/source/main.pas b/source/main.pas index 08856f48..cff18a37 100644 --- a/source/main.pas +++ b/source/main.pas @@ -852,6 +852,7 @@ type FOperatingGrid: TBaseVirtualTree; FActiveDbObj: TDBObject; FCriticalSection: TRTLCriticalSection; + FIsWine: Boolean; procedure ParseCommandLineParameters(Parameters: TStringlist); procedure SetDelimiter(Value: String); @@ -1281,6 +1282,8 @@ var DpiScaleFactor: Double; FunctionCategories: TStringList; miGroup, miFilterGroup, miFunction, miFilterFunction: TMenuItem; + NTHandle: THandle; + wine_nt_to_unix_file_name: procedure(p1:pointer; p2:pointer); stdcall; begin caption := APPNAME; setLocales; @@ -1305,6 +1308,14 @@ begin SetString(AppDescription, PChar(Info), dwInfoSize-1); FreeMem(ptrVerBuf); + // Detect if we're running on Wine, not on native Windows + // Idea taken from http://ruminatedrumblings.blogspot.com/2008/04/detecting-virtualized-environment.html + NTHandle := LoadLibrary('NTDLL.DLL'); + if NTHandle>32 then + wine_nt_to_unix_file_name := GetProcAddress(NTHandle, 'wine_nt_to_unix_file_name'); + FIsWine := Assigned(wine_nt_to_unix_file_name); + FreeLibrary(NTHandle); + // "All users" folder for HeidiSQL's data (All Users\Application Data) DirnameCommonAppData := GetShellFolder(CSIDL_COMMON_APPDATA) + '\' + APPNAME + '\'; @@ -6200,17 +6211,20 @@ var NeededWidth : Integer; Tree: TVirtualStringTree; begin - Tree := TVirtualStringTree(Sender); - HintText := Tree.Text[Node, Column]; - HintText := sstr(HintText, SIZE_KB); - LineBreakStyle := hlbForceMultiLine; - // Check if the list has shortened the text - r := Tree.GetDisplayRect(Node, Column, True); - DisplayedWidth := r.Right-r.Left; - NeededWidth := Canvas.TextWidth(HintText) + Tree.TextMargin*2; - // Disable displaying hint if text is displayed completely in list - if NeededWidth <= DisplayedWidth then - HintText := ''; + // Disable tooltips on Wine, as they prevent users from clicking + editing clipped cells + if not FIsWine then begin + Tree := TVirtualStringTree(Sender); + HintText := Tree.Text[Node, Column]; + HintText := sstr(HintText, SIZE_KB); + LineBreakStyle := hlbForceMultiLine; + // Check if the list has shortened the text + r := Tree.GetDisplayRect(Node, Column, True); + DisplayedWidth := r.Right-r.Left; + NeededWidth := Canvas.TextWidth(HintText) + Tree.TextMargin*2; + // Disable displaying hint if text is displayed completely in list + if NeededWidth <= DisplayedWidth then + HintText := ''; + end; end;