[SOLVED] GUI type detection lazarus / 31-LCL ---------------------------------------------------------------------- Raul_ES · 2020-03-12 01:44 Hi, do you know how can I make my program detect the GUI library is being used? I mean that I need to detect if it is GTK2 , QT4, QT5, version of the QT compilation...those things. The following doesn't work Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$ifdef lclgtk}  _GUI_ := 'GTK';{$endif} thanks ---------------------------------------------------------------------- eljo · 2020-03-12 02:37 works for me Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetGUITarget:string;begin{$IFDEF LCLGTK}  result := 'GTK';{$ENDIF}{$IFDEF LCLGTK2}  result := 'GTK2';{$ENDIF}{$IFDEF LCLWIN32}  result := 'Win32';{$ENDIF}{$IFDEF LCLQT}  result := 'QT';{$ENDIF}end; ---------------------------------------------------------------------- lucamar · 2020-03-12 12:22 For completeness sake, if you ever want to get that info at run time, you can use the constants in uniit LCLPlatformDef. This function, for example, returns a string with the Lazarus version (taken from unit LazVersion) and widgetset for, say, an "about box": Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  LCLPlatformDef, LazVersion; const  sLazVers = '%d.%d.%d (%s)'; {version (widgetset)} function LazarusInfo: String;var  platform: String;begin  platform := LCLPlatformDisplayNames[GetBuildLCLWidgetType];  Result := Format(sLazVers,                   [laz_major, laz_minor, laz_release, platform]);end; Note, though, that GetBuildLCLWidgetType() will tell you the widgetset for which Lazarus itself was built which, while also  the default it uses to build your apps, might not coincide if, for example, you're cross-compiling to some other target. ---------------------------------------------------------------------- Raul_ES · 2020-03-13 17:08 Thanks, that's exactly what I need regards, ---------------------------------------------------------------------- Zoran · 2020-03-13 18:35 Quote from: lucamar on March 12, 2020, 01:22:46 pmNote, though, that GetBuildLCLWidgetType() will tell you the widgetset for which Lazarus itself was built which, while also  the default it uses to build your apps, might not coincide if, for example, you're cross-compiling to some other target. Yes. Therefore, instead of GetBuildLCLWidgetType(), better use GetDefaultLCLWidgetType() from unit InterfaceBase. ---------------------------------------------------------------------- lucamar · 2020-03-13 19:59 Quote from: Zoran on March 13, 2020, 07:35:50 pmYes. Therefore, instead of GetBuildLCLWidgetType(), better use GetDefaultLCLWidgetType() from unit InterfaceBase. Good catch. I (mistakenly) thought it just read LCLPlatformDef.BuildLCLWidgetType but it appears it (and the complementary GetLCLWidgetTypeName()) reads the current widgetset if any and uses BuildLCLWidgetType only as fallback. Thanks, Zoran. Never go to bed without learning something new, they say ---------------------------------------------------------------------- Zoran · 2020-03-13 22:03 Quote from: lucamar on March 13, 2020, 08:59:05 pmQuote from: Zoran on March 13, 2020, 07:35:50 pmYes. Therefore, instead of GetBuildLCLWidgetType(), better use GetDefaultLCLWidgetType() from unit InterfaceBase. Good catch. I (mistakenly) thought it just read LCLPlatformDef.BuildLCLWidgetType but it appears it (and the complementary GetLCLWidgetTypeName()) reads the current widgetset if any and uses BuildLCLWidgetType only as fallback. Thanks, Zoran. Never go to bed without learning something new, they say You are welcome. I'm not surprised by your mistake, I think the name of this function is confusing actually -- GetDefaultLCLWidgetType -- better name would be GetCurrentLCLWidgetType, or simply (perhaps the best) GetWidgetType.