Can I add a dark theme to my form? lazarus / 34-Windows ---------------------------------------------------------------------- AMJF · 2022-04-25 21:43 Is there a relatively simple way of making my own designed form on Lazarus IDE match the dark theme of Windows 10? I hate the way that the form currently stands out as looking bright, in stark contrast. I have tried changing the Colour setting for each component, but it doesn't look right and the text in the dialogs is still dark, and not light on dark as in the dark theme. I would imagine a single setting would be needed, but is there more to it than that? ---------------------------------------------------------------------- AlexTP · 2022-04-25 21:46 Method to make the form title dark https://github.com/Alexey- T/CudaText/blob/master/comp/win32titlestyler.pas ---------------------------------------------------------------------- AMJF · 2022-04-26 04:27 I'm not sure how to add this to my own code. ---------------------------------------------------------------------- AlexTP · 2022-04-26 07:34 Import the unit: "uses win32titlestyler". Then call its procedure in your form's OnShow. ---------------------------------------------------------------------- AMJF · 2022-04-26 08:58 Quote from: AlexTP on April 26, 2022, 09:34:12 amImport the unit: "uses win32titlestyler". Then call its procedure in your form's OnShow. I copied the raw text of the .pas unit from github to a .pas file, added "win32titlestyler" to the "uses" part at the start of my program's unit, then added the call command to OnShow, with my program's form (fADL) as a variable and True for the Boolean variables. Nothing happened. What should I do now? ---------------------------------------------------------------------- wp · 2022-04-26 09:29 I can confirm AMJF's observation that unit win32titlestyler does nothing (except for making the diffuse form shadow a bit darker in Win 11). ---------------------------------------------------------------------- Zoran · 2022-04-26 10:23 Instead of adding win32titlestyler unit directly, you can add this unit to your project. 1. It can be safely added to a cross-platform project, it just does nothing on non-windows systems. 2. On windows os, this unit takes care of adding a call to ApplyFormDarkTitle function when each form is shown the first time. 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 unit TitleStylerHelper; {$mode ObjFPC}{$H+} interface // On non-windows systems, this is empty unit!                           implementation                                       {$ifdef MSWINDOWS} uses  SysUtils, Forms, win32titlestyler; type   TTitleStyler = class(TObject)  private    class var      TitleStyler: TTitleStyler;  public    class procedure Init;    class procedure Final;     procedure NewFormAdded(Sender: TObject; Form: TCustomForm);    procedure FormFirstShow(Sender: TObject);  end; class procedure TTitleStyler.Init;begin  TitleStyler := TTitleStyler.Create;  Screen.AddHandlerFormAdded(@TitleStyler.NewFormAdded);end; class procedure TTitleStyler.Final;begin  Screen.RemoveAllHandlersOfObject(TitleStyler);  TitleStyler.Free;end; procedure TTitleStyler.NewFormAdded(Sender: TObject; Form: TCustomForm);begin  Form.AddHandlerFirstShow(@TitleStyler.FormFirstShow);end; procedure TTitleStyler.FormFirstShow(Sender: TObject);var  F: TForm;begin// Unfortunately, as currently implemented ApplyFormDarkTitle// requires TForm, not TCustomForm.// So, this cannot work for forms not derived from TForm.  if Sender is TForm then begin    F := TForm(Sender);    F.HandleNeeded;    ApplyFormDarkTitle(F, True, True);  end;end; initialization  TTitleStyler.Init; finalization  TTitleStyler.Final; {$endif} end. ---------------------------------------------------------------------- AMJF · 2022-04-26 11:10 I replaced win32titlestyler with titlestylehelper in the "uses" part of my project, and removed the procedure in OnShow for my form, but still nothing happened. Could I try modifying win32titlestyler instead? ---------------------------------------------------------------------- Zoran · 2022-04-26 11:42 Quote from: AMJF on April 26, 2022, 01:10:08 pmI replaced win32titlestyler with titlestylehelper in the "uses" part of my project, and removed the procedure in OnShow for my form, but still nothing happened. Of course the helper can work only if the original solution work. All it does is what I said in my previous post. Quote from: AMJF on April 26, 2022, 01:10:08 pmCould I try modifying win32titlestyler instead? As I see it's MIT licensed. It is a permissive license, so you can, just make sure you comply with mit license. ---------------------------------------------------------------------- dbannon · 2022-04-26 12:03 AMJF, sorry, a silly question, your Windows box is switched to Dark Theme isn't it ?   And its not an un-updated, early Windows 10 that did not support Dark Themes they way they do now ? Davo ---------------------------------------------------------------------- AMJF · 2022-04-26 12:20 Quote from: dbannon on April 26, 2022, 02:03:45 pmAMJF, sorry, a silly question, your Windows box is switched to Dark Theme isn't it ?   And its not an un-updated, early Windows 10 that did not support Dark Themes they way they do now ? Davo Well, Windows Explorer is on Dark Theme, yes. As far as I know, it's the latest Windows 10. ---------------------------------------------------------------------- wp · 2022-04-26 13:33 Just my two cents: It is my impression that the Windows dark mode still is not finished, even in Win 11. Just switched to dark mode in the system settings -> the explorer becomes dark. I delete a large folder -> the message form showing the progress of the process is bright. Excel 2016's main form is dark, but any dialog which I open is bright. A variety of applications, even by Microsoft, are bright to begin with: Task manager, Computer administration, Device manager, RegEdit, Write... ---------------------------------------------------------------------- AMJF · 2022-04-26 15:19 In that case, It's a shame I can't manually change all the colours, invert all the colours of the text and background, etc so that they'll look as good as Dark Theme. Unless there's a guide somewhere? ---------------------------------------------------------------------- AMJF · 2022-04-26 18:35 So is there a way I can change the colours on my form to mimic a dark theme and invert the text colours so that my whole form looks like the Steam interface? ---------------------------------------------------------------------- AlexTP · 2022-04-26 20:54 Yes, if you use ATFlatControls or another lib like it. ---------------------------------------------------------------------- paweld · 2022-04-27 13:21 Dark mode can be achieved using Qt5. Download the unit: https://github.com/doublecmd/doublecmd/blob/master/ src/platform/win/udarkstyle.pas and call it in your application: 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 udarkstyle.ApplyDarkStyle; You must set the widgetset for your project to qt5 ---------------------------------------------------------------------- alaa123456789 · 2022-04-27 18:03 anyone has a tutorial how t use qt5 in Lazarus (video/ text with photos ) ---------------------------------------------------------------------- dbannon · 2022-04-27 23:47 In Lazarus ? Trivial, no tutorial needed. In the project you are working on, Project->ProjectOption->AdditionsAndOverRides(down near bottom)->LCLWidgetType. Add qt5 If your project has several modes, do that for each. But you will also have to install Qt5 libraries on your Windows box, thats possibly more of a task and one I cannot help with. Your  end user will also need the qt5 libraries by the way. Davo ---------------------------------------------------------------------- zeljko · 2022-04-28 10:57 Just wondering if initialization section is needed for Qt5 ? ---------------------------------------------------------------------- dbannon · 2022-04-28 11:55 Total guess work, I have never used QT on Windows. But I can get any colour scheme I like with Qt5 and Linux, with no extra code in the app itself.  (Obviously, Zeljk knows this but for OP)  An external app, supplied by the QT people themselves (called qt5ct on Linux) sets up colour profiles, you launch your app with an Env Var that tell it, a QT app, which colour profile to use. Works flawlessly on Linux, never tried it anywhere else. Davo ---------------------------------------------------------------------- tetrastes · 2022-04-28 11:58 Dark theme, dark theme... Did anyone note that at paweld's picture PageControl is drawn inconsistently with other controls? And black font on dark grey background is almost unreadable? ---------------------------------------------------------------------- Fred vS · 2022-04-28 12:12 Quote from: tetrastes on April 28, 2022, 01:58:41 pmDark theme, dark theme... Did anyone note that at paweld's picture PageControl is drawn inconsistently with other controls? And black font on dark grey background is almost unreadable? Hello. You may also consider the MSEgui widgetset. It dont need to install any dependencies, works for Windows, Linux, FreeBSD, is 100% Pascal code and you may use dark, light, what-ever- theme you want. Fre;D ---------------------------------------------------------------------- Gald · 2022-04-28 16:45 Quote from: Fred vS on April 28, 2022, 02:12:52 pmYou may also consider the MSEgui widgetset. Hi! Nice to know. Can you help me to understand the step number 7? "In 'Project'-'Open' select 'sourcedirectory/apps/demo/demo.prj'." https://github.com/mse-org/mseide-msegui/#installation I can't find it. ---------------------------------------------------------------------- Fred vS · 2022-04-28 16:54 Quote from: Gald on April 28, 2022, 06:45:36 pmQuote from: Fred vS on April 28, 2022, 02:12:52 pmYou may also consider the MSEgui widgetset. Hi! Nice to know. Can you help me to understand the step number 7? "In 'Project'-'Open' select 'sourcedirectory/apps/demo/demo.prj'." https://github.com/mse-org/mseide-msegui/#installation I can't find it.  Hello. When you have downloaded and unzipped the source (from https://github.com/mse-org/mseide-msegui/archive/master.zip) in the directory of your choice (let say "sourcedirectory"), open the project  '/sourcedirectory/apps/demo/demo.prj'. In my case it is: /home/fred/mseide-msegui/apps/demo/demo.prj Fre;D ---------------------------------------------------------------------- Gald · 2022-04-28 17:15 Quote from: Fred vS on April 28, 2022, 06:54:39 pmin the directory of your choice (let say "sourcedirectory"), open the project  '/sourcedirectory/apps/demo/demo.prj'. B-b-but open with what? How? Lazarus can't open that file (unless text) and MSEide even. ---------------------------------------------------------------------- Gald · 2022-04-28 17:36 I tried to go to: Project > Options > Tab "Storage", hit the "..." button, and saved it. Then i Opened it: Project > Open > 'demo.prj' and run (Continue). But I'm getting the following error: "gdb.exe -interpreter=mi -nx" ---------------------------------------------------------------------- Fred vS · 2022-04-28 17:41 Quote from: Gald on April 28, 2022, 07:15:59 pmQuote from: Fred vS on April 28, 2022, 06:54:39 pmin the directory of your choice (let say "sourcedirectory"), open the project  '/sourcedirectory/apps/demo/demo.prj'. B-b-but open with what? How? Lazarus can't open that file (unless text) and MSEide even. With MSEide project files (.prj) are loaded with the menu item "Project" "Open". Lazarus (afaik) cannot load 'prj' files. ---------------------------------------------------------------------- Fred vS · 2022-04-28 17:45 Quote from: Gald on April 28, 2022, 07:36:42 pmI tried to go to: Project > Options > Tab "Storage", hit the "..." button, and saved it. Then i Opened it: Project > Open > 'demo.prj' and run (Continue). But I'm getting the following error: "gdb.exe -interpreter=mi -nx" Do you have gdb.exe installed on your system? [EDIT] If gdb.exe is located in a custom path you may adjust it in menu "Settings" "Configure MSEide" "Debugger path". ---------------------------------------------------------------------- Gald · 2022-04-28 18:14 I get it now! Thank you so much, Fred! ---------------------------------------------------------------------- Fred vS · 2022-04-28 18:15 Quote from: Gald on April 28, 2022, 08:14:23 pmI get it now! Thank you so much, Fred! ---------------------------------------------------------------------- zeljko · 2022-04-28 18:48 Quote from: tetrastes on April 28, 2022, 01:58:41 pmDark theme, dark theme... Did anyone note that at paweld's picture PageControl is drawn inconsistently with other controls? And black font on dark grey background is almost unreadable? That's because he uses fusion theme, not windows one with dark colors ---------------------------------------------------------------------- zamtmn · 2022-04-28 20:01 Quote from: alaa123456789 on April 27, 2022, 08:03:28 pmanyone has a tutorial how t use qt5 in Lazarus (video/ text with photos ) small instruktion to make lazarus dark: https://forum.lazarus.freepasc al.org/index.php/topic,55550.msg435622.html#msg435622 ---------------------------------------------------------------------- alaa123456789 · 2022-04-30 05:29 Quote from: dbannon on April 28, 2022, 01:47:13 amIn Lazarus ? Trivial, no tutorial needed. In the project you are working on, Project->ProjectOption->AdditionsAndOverRides(down near bottom)->LCLWidgetType. Add qt5 If your project has several modes, do that for each. But you will also have to install Qt5 libraries on your Windows box, thats possibly more of a task and one I cannot help with. Your  end user will also need the qt5 libraries by the way. Davo thanks Davo for the advice , i followed it , ad i added all qt dlls , qt5pas1.dll to same folder but i got the messagee as shown in capture.png anyone has experience with this please help thanks in advance ---------------------------------------------------------------------- howardpc · 2022-04-30 05:38 One thing to check is that the bitness of your Lazarus and the dlls is the same. 64-bit dlls will not work alongside a 32-bit executable. ---------------------------------------------------------------------- alaa123456789 · 2022-04-30 05:45 Quote from: howardpc on April 30, 2022, 07:38:51 amOne thing to check is that the bitness of your Lazarus and the dlls is the same. 64-bit dlls will not work alongside a 32-bit executable. is there any qt5pas1.dll x64 or only x32? ---------------------------------------------------------------------- Gald · 2022-04-30 06:09 Hello guys! I downloaded this version: https://download.qt.io/archive/qt/5.12/5.12.12/ The reason I choose 5.12.12 is because of this line of the readme.txt that came with Lazarus: "They only work with qt5 >= 5.6.0 or superior." But I'm having problems with these three missing DLLs on run the project: qt5core.dllqt5gui.dllqt5network.dll But I don't even have it on my computer. What am I doing wrong? Ps: the Wiki is completely outdated, including links and steps. ---------------------------------------------------------------------- paweld · 2022-04-30 07:53 After install qt-opensource-windows-x86-5.12.12.exe you have to copy the following files to the application directory: - libgcc_s_dw2-1.dll - libstdc++-6.dll - libwinpthread-1.dll - Qt5Core.dll - Qt5Gui.dll - Qt5Network.dll - Qt5PrintSupport.dll - Qt5Widgets.dll With the default installation, the files are located in the directory: C:\Qt\Qt5.12.12\5.12.12\mingw73_32\bin\ And to subfolders: * pluginsplatforms: - qminimal.dll - qwindows.dll z C:\Qt\Qt5.12.12\5.12.12\mingw73_32\plugins\platforms\ * pluginsstyles:: - qwindowsvistastyle.dll z C:\Qt\Qt5.12.12\5.12.12\mingw73_32\plugins\styles\ ---------------------------------------------------------------------- tetrastes · 2022-05-03 20:49 Quote from: zeljko on April 28, 2022, 08:48:52 pmQuote from: tetrastes on April 28, 2022, 01:58:41 pmDark theme, dark theme... Did anyone note that at paweld's picture PageControl is drawn inconsistently with other controls? And black font on dark grey background is almost unreadable? That's because he uses fusion theme, not windows one with dark colors Strange explanation. So this inconsistency is appropriate for Fusion theme? And what I have to write instead of 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 const  StyleName: WideString = 'Fusion'; to use "windows one with dark colors"? P.S. And there is another badly looking inconsistency: arrows in ListBox scroll bar are black, while arrow in ComboBox is white.