<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Lazarus Pascal - Enable darkmode/darktheme in your Windows application - Delphi, Lazarus, Free Pascal				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 01:19:38 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Lazarus Pascal - Enable darkmode/darktheme in your Windows application</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-6033</link>
                        <pubDate>Wed, 03 Sep 2025 07:38:05 +0000</pubDate>
                        <description><![CDATA[Thanks for the tip!In the example I&#039;m already using a unit from metadarkstyle (udarkstyle.pas), which I probably should have mentioned (correcting the original post in a minute). Totally ove...]]></description>
                        <content:encoded><![CDATA[<p>Thanks for the tip!<br />In the example I'm already using a unit from metadarkstyle (udarkstyle.pas), which I probably should have mentioned (correcting the original post in a minute). Totally overlooked mentioning that. &#x1f60a; </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-6033</guid>
                    </item>
				                    <item>
                        <title>RE: Lazarus Pascal - Enable darkmode/darktheme in your Windows application</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-6032</link>
                        <pubDate>Wed, 03 Sep 2025 06:37:28 +0000</pubDate>
                        <description><![CDATA[have a look at metadarkstyle
that also let you set the ide of lazarus to dark mode.]]></description>
                        <content:encoded><![CDATA[<p>have a look at <a title="darkstyle in lazarus" href="https://github.com/zamtmn/metadarkstyle" target="_blank" rel="noopener">metadarkstyle</a></p>
<p>that also let you set the ide of lazarus to dark mode.</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-6032</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - Enable darkmode/darktheme in your Windows application</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-5872</link>
                        <pubDate>Sat, 28 Jun 2025 11:34:32 +0000</pubDate>
                        <description><![CDATA[I&#039;m not a daily Windows user, and Lazarus (at the moment) does not follow the Windows settings when set to Darkmode.Understandably, I have some applications where Windows users would like to...]]></description>
                        <content:encoded><![CDATA[<p>I'm not a daily Windows user, and Lazarus (at the moment) does not follow the Windows settings when set to Darkmode.<br />Understandably, I have some applications where Windows users would like to see DarkMode, but the widgetset (LCL) does not support this at the time.</p>
<p>After a lot of searching, I did find a way that at least <strong>looks</strong> like it is darkmode - keep in mind that its pretty close but not perfect.<br />This most likely only works with Windows 10 (I believe it even requires certain Windows 10 updats) and Windows 11.<br />Tested with Win32 and Win64 binaries.</p>
<p>These are the steps (files attached - extract in project directory) to make your application start (!) in darkmode under Windows, when Windows is set to darkmode.</p>
<p>Note that changing dark/light mode while the application is running, is not working at the moment (suggestions/input most welcome).</p>
<p><span style="text-decoration: underline"><strong>Source</strong></span>: <strong>udarkstyle.pas</strong> and <strong>uWin32WidgetSetDark.pas </strong>from <a href="https://github.com/zamtmn/metadarkstyle" target="_blank" rel="noopener">metadarkstyle</a></p>
<p> </p>
<p>So the steps I did: First the needed uses clause:</p>
<pre contenteditable="false">Uses ....
  {$IFDEF Windows}
  , uWin32WidgetSetDark, uDarkStyle
  {$ENDIF}  
  ... ;</pre>
<p> </p>
<p>To make it work fully, I've added this to my main forms "<strong>OnCreate</strong>" event - this fixes some minor details that for some reason are not done automatically:</p>
<pre contenteditable="false">procedure TForm1.FormCreate(Sender: TObject);
begin
  ...
  if IsDarkModeAppearance then ApplyDarkStyle; 
  ...
end;</pre>
<p> </p>
<p>The function "<strong>IsDarkModeAppearance</strong>" detects darkmode kind-a cross platform, this is the part needed for Windows:</p>
<pre contenteditable="false">function IsDarkModeAppearance:boolean;
const
  KEYPATH = '\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize';
  KEYNAME = 'AppsUseLightTheme';
var
  LightKey: boolean;
  Registry: TRegistry;
begin
  Result := false;
  Registry := TRegistry.Create;
  try
    Registry.RootKey := HKEY_CURRENT_USER;
    if Registry.OpenKeyReadOnly(KEYPATH) then
      begin
        if Registry.ValueExists(KEYNAME) then
          LightKey := Registry.ReadBool(KEYNAME)
        else
          LightKey := true;
      end
    else
      LightKey := true;
    Result := not LightKey
  finally
    Registry.Free;
  end;
end;    </pre>
<p> </p>
<p>Note: The modifications I made were done in "<strong>uDarkStyle.pas</strong>" (line 254):</p>
<pre contenteditable="false">// mod to make sure light mode works proper as well
// was: AppMode := TPreferredAppMode(pamDefault);   

if ShouldAppsUseDarkMode then
  AppMode := pamForceDark
else
  AppMode := TPreferredAppMode(pamDefault);
</pre>
<p>What this does is make sure things work properly in light mode (pamDefault) and dark mode (pamForceDark). The latter makes sure the titlebar is dark as well.</p>
<p>Based on slightly modified excellent and extensive work by <strong>Alexander Koblov</strong> (<a href="https://github.com/doublecmd/doublecmd" target="_blank" rel="noopener">Double Commander</a>).</p>
689]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-enable-darkmode-darktheme-in-your-application/#post-5872</guid>
                    </item>
							        </channel>
        </rss>
		