Receiving WM_SETTINGCHANGE instead of WM_THEMECHANGED message on theme change Win32 app

Shyam Butani 135 Reputation points

I'm running Win32 app on Windows 11. I want to capture theme-change event, but I'm receiving WM_SETTINGCHANGE instead of WM_THEMECHANGED message when system theme is changed (from settings).

Find below sample code snippet to get an idea how I'm handling messages.

LRESULT CALLBACK WindowProc(HWND hWnd, UINT messageCode, WPARAM wParam, LPARAM lParam)
    switch (messageCode)




        return DefWindowProc(hWnd, messageCode, wParam, lParam);

    return 0;

Please correct me if I'm missing anything here. OR If any way to identify the theme-change event from WM_SETTINGCHANGE.

And, when I change system theme from the settings, I observed that WM_SETTINGCHANGE is being invoked few amount of times (2-12 times depending on the prev theme and new theme).


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,469 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,603 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jeanine Zhang-MSFT 9,346 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    WM_SETTINGCHANGE message: Applications should send WM_SETTINGCHANGE to all top-level windows when they make changes to system parameters. A message that is sent to all top-level windows when the SystemParametersInfo function changes a system-wide setting or when policy settings have changed.

    WM_THEMECHANGED message: Broadcast to every window following a theme change event. The window is sent a WM_THEMECHANGED message at the end of a SetWindowTheme call.

    As far as I'm concerned, when you change the system theme from settings you will receive WM_SETTINGCHANGE message.

    when I change system theme from the settings, I observed that WM_SETTINGCHANGE is being invoked few amount of times

    The Settings app broadcasts WM_SETTINGSCHANGE messages using SendMessageTimeout, which sends the WM_SETTINGCHANGE message to all top-level windows. The function does not return until each window has timed out. Therefore, the total wait time can be up to the value of uTimeout multiplied by the number of top-level windows. As a result, you may receive multiple messages.

    I suggest you could refer to the thread:

    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 additional answers

Sort by: Most helpful