WinRT getting callbacks to Win32 application

Björn Eiríksson 21 Reputation points

I am having problem getting callbacks from WinRT to Win32 application.

This code builds...... but I never get the callback even if I toggle HighContrast on and off in the control panel.

Bellow is my code, which builds and does not crash when I run it, but the OutputDebugString inside of the callback I never get.

Is there something I should be doing differently ?

OutputDebugStringW(L"Adding callback");

   settings->add_HighContrastChanged(Microsoft::WRL::Callback<ABI::Windows::Foundation::ITypedEventHandler< abi_vm::AccessibilitySettings*, IInspectable*>>
        [](auto&& s, IInspectable*) -> HRESULT
            OutputDebugStringW(L"High contrast changed");
            return 0;


Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
474 questions
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.
1,988 questions
No comments
{count} votes

Accepted answer
  1. Castorix31 69,256 Reputation points

    On my OS (Windows 10 21H1), I only get this event with Packaged apps, not Desktop apps (while other events work)

    For example in UWP, in the MainPage class :

     hcChangedRevoker = accSettings.HighContrastChanged(winrt::auto_revoke, [this](winrt::Windows::UI::ViewManagement::AccessibilitySettings const&, winrt::Windows::Foundation::IInspectable const&)
                    // code...


     Windows::UI::ViewManagement::AccessibilitySettings accSettings;
     Windows::UI::ViewManagement::AccessibilitySettings::HighContrastChanged_revoker hcChangedRevoker;

0 additional answers

Sort by: Most helpful