Changing the primary display using the Win32 API

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • monitorpanel

  • Most users of my Lunar app (https://lunar.fyi) that were coming from Windows, have been praising the Windows multi monitor experience while the Mac felt limited in the handling of external monitors.

    I admit that finding a way to change monitor brightness [1] or turn off individual displays [2] wasn’t as straightforward and needed a lot of reverse engineering. But macOS has a much nicer API [3] for configuring screen position, resolution, mirroring etc.

    It’s not without its quirks however, I ran into a lot of bugs while developing the Blackout feature when having to create multiple mirror sets with multiple displays in each one. I finally had to reverse engineer the MonitorPanel.framework that’s used by System Preferences to get that functionality. [4]

    From my understanding, Windows has a native way of disabling a display in software so this wouldn’t even be needed there.

    [1] https://alinpanaitiu.com/blog/journey-to-ddc-on-m1-macs/

    [2] https://lunar.fyi/#blackout

    [3] https://developer.apple.com/documentation/coregraphics/quart...

    [4] https://github.com/alin23/monitorpanel

  • Lunar

    Intelligent adaptive brightness for your external monitors

  • Most users of my Lunar app (https://lunar.fyi) that were coming from Windows, have been praising the Windows multi monitor experience while the Mac felt limited in the handling of external monitors.

    I admit that finding a way to change monitor brightness [1] or turn off individual displays [2] wasn’t as straightforward and needed a lot of reverse engineering. But macOS has a much nicer API [3] for configuring screen position, resolution, mirroring etc.

    It’s not without its quirks however, I ran into a lot of bugs while developing the Blackout feature when having to create multiple mirror sets with multiple displays in each one. I finally had to reverse engineer the MonitorPanel.framework that’s used by System Preferences to get that functionality. [4]

    From my understanding, Windows has a native way of disabling a display in software so this wouldn’t even be needed there.

    [1] https://alinpanaitiu.com/blog/journey-to-ddc-on-m1-macs/

    [2] https://lunar.fyi/#blackout

    [3] https://developer.apple.com/documentation/coregraphics/quart...

    [4] https://github.com/alin23/monitorpanel

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • windows-driver-docs

    The official Windows Driver Kit documentation sources

  • I thought ChangeDisplaySettingsEx and EnumDisplaySettings was superseded by SetDisplayConfig and QueryDisplayConfig, respectively? https://github.com/MicrosoftDocs/windows-driver-docs/blob/st... calls ChangeDisplaySettingsEx "legacy API".

    From my experience, changing topology using SetDisplayConfig() is straightforward.

  • SatouinDp

    Quickly switch primary displays on Windows

  • I wrote an F# tool specifically for changing the primary display not too long ago. This is the code that calls the Win32 API to query the displays and set the primary one.

    https://github.com/steinuil/SatouinDp/blob/master/DisplayDev...

    One thing I never figured out was how to map the displays you get from EnumDisplayDevices to the names you see in the display settings, or how to list them in a consistent order.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts