a b 16 Reputation points


I have a C++ Windows app (Qt) that uses Win32 titlebars and I'm working on adding dark theme support for it. I learned that you can set DWMWA_USE_IMMERSIVE_DARK_MODE attribute on a window so that title bars will be rendered in dark theme but I have a couple of questions about it.

  1. Docs for DWMWA_USE_IMMERSIVE_DARK_MODE state that if its value is TRUE then title bar will follow system-wide dark theme setting. This doesn't match with actual behaviour at runtime since when I tried to set it to TRUE, title bar became black even though the system was in light theme. Is documentation incorrect? For the record, actual behaviour is desired since documented behaviour will not allow to override dark theme setting in app.
    1. What is its relationship with DWMWA_CAPTION_COLOR attribute? I tried to set DWMWA_CAPTION_COLOR to dark color without touching DWMWA_USE_IMMERSIVE_DARK_MODE and title bar still became dark. Do I need to use DWMWA_USE_IMMERSIVE_DARK_MODE when I set
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,448 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,562 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,423 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 15,831 Reputation points Microsoft Vendor

    Hi @a b

    After reading your latest comment, I understand your needs.

    Support Dark and Light themes in Win32 apps

    This article provides a complete introduction,

    • How to detect the current theme of the system (Dark or Light) ;
    • How to use DwmSetWindowAttribute.

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments