<?xml version="1.0" encoding="utf-8"?> 
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <id>https://thatcat.space/tags/windows/</id>
    <title>Windows - Tag - that cat space</title>
    <link href="https://thatcat.space/tags/windows/index.xml" rel="self" type="application/atom+xml" />
    <link href="https://thatcat.space/tags/windows/" />
    <subtitle>Windows - Tag - that cat space</subtitle>
    <generator uri="https://gohugo.io/" version="0.135.0">Hugo</generator><updated>2023-03-25T23:47:56+03:00</updated><entry>
            <title type="html"><![CDATA[Dark window frame on Windows 10]]></title>
            <link href="https://thatcat.space/notes/4/" rel="alternate" type="text/html" /><link href="https://thatcat.space/ru/notes/4/" rel="alternate" type="text/html" hreflang="ru" />
            <published>2023-03-25T23:47:56+03:00</published>
            <updated>2024-02-04T09:28:46+03:00</updated>
            <author>
                <name>Author</name>
            </author>
            <id>https://thatcat.space/notes/4/</id>
            <content type="html"><![CDATA[<p>From time to time I&rsquo;m encountering a problem that app has dark color theme, but window frame is light. So here I&rsquo;ll save two ways to change it on Windows 10.</p>
<h2 id="for-app-users">For app users</h2>
<p>I&rsquo;ll tell you right away: this way won&rsquo;t be useful if the accent color is important to you.</p>
<p>Open Registry Editor and find <code>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM</code> section. You&rsquo;ll need the following parameters from it:</p>
<ul>
<li><code>ColorPrevalence</code>: DWORD = 1<br>
This parameter allows to use accent color as title bar color.</li>
<li><code>AccentColor</code> and <code>AccentColorInactive</code>: DWORD = color in ABGR format (hexadecimal).<br>
Colors for active and inactive mode.</li>
</ul>
<p>Here&rsquo;s an example of registry file where color <code>#000000</code> is used for active window title and <code>#212121</code> is used for inactive one:</p>
<pre>Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]
&#34;ColorPrevalence&#34;=dword:00000001
&#34;AccentColor&#34;=dword:ff000000
&#34;AccentColorInactive&#34;=dword:ff212121</pre><h2 id="for-app-coders">For app coders</h2>
<p>You&rsquo;ll need <a href="https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute" target="_blank" rel="noopener noreffer">DwmSetWindowAttribute</a>
 function:</p>
<pre>HRESULT DwmSetWindowAttribute(
       HWND    hwnd,        // window
       DWORD   dwAttribute, // attribute itself
  [in] LPCVOID pvAttribute, // value
       DWORD   cbAttribute  // value size in bytes
);</pre><p>Attribute values are described by <a href="https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute" target="_blank" rel="noopener noreffer">DWMWINDOWATTRIBUTE</a>
 but we specifically interested in <code>DWMWA_USE_IMMERSIVE_DARK_MODE</code>. Documentation says it&rsquo;s equal to <code>20</code>, however until 20H1 version <a href="https://stackoverflow.com/a/62811758" target="_blank" rel="noopener noreffer">the value has been equal to <code>19</code></a>
.</p>
<p>That&rsquo;s how i&rsquo;ve tried to implement <a href="https://github.com/ultimatepp/ultimatepp/pull/77" target="_blank" rel="noopener noreffer">autodetect of window frame theme in Ultimate++</a>
:</p>
<pre>  HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
  DllFn(DwmSetWindowAttribute, &#34;dwmapi.dll&#34;, &#34;DwmSetWindowAttribute&#34;);
  if (DwmSetWindowAttribute) {
    BOOL useDarkTheme = IsDarkTheme(); 
    DwmSetWindowAttribute(
      top-&gt;hwnd, 20, /* 20 is DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE */
      &amp;useDarkTheme, sizeof(useDarkTheme));
  }</pre>]]></content>
        </entry>
</feed>
