Search code examples
c++windowswinapiwallpaper

Monitors position on Windows wallpaper


I am working on C++ application to manage wallpapers accross multiple monitors on Windows, like what UltraMon and DisplayFusion do but with more options.

Everthing is working well but monitors placement.

My desktop has three monitors arranged like that (ignore N°4) enter image description here

But when I look at the wallpaper file generated by UltraMon, the thrid monitor (the small one) does not have the same position : enter image description here

By using EnumDisplayMonitors and GetMonitorInfo functions I get these data :

0: 1920x1080 at 1920x0
1: 1920x1080 at 0x0 primary
2: 800x480 at -800x-480 

Which corresponds to my arrangement, but differs from the wallpaper file.

How to know where is placed the image in the global wallpaper file to have it displayed on the right monitor ? I guess the author of UltraMon found the right way 'cause it works perfectly.

(I asked this question on UltraMon forum too).


Solution

  • Thanks to the article quoted by Raymon Chen I figured it out. http://blogs.msdn.com/b/oldnewthing/archive/2007/09/24/5083738.aspx

    Two things to know :

    1. the trick of having different wallpaper on each monitor is to build a "macro wallpaper" and make it tiled accross the desktop
    2. the tile begins à 0;0 on the primary monitor

    Knowing that, any monitor which is on left or top of the primary monitor is on another tile of the wallpaper.

    Let's see it in image : enter image description here

    in green we have the actual desktop, which uses four tiles of the wallpaper image (in red).

    Now it's time to code that !