How does win32 draw wallpaper?

Started by
10 comments, last by Steven Hansen 18 years, 2 months ago
So - I have dual monitors, and want different wallpaper for each. I don't need any of the hokey extras that typical multi-monitor management systems sport, just 2 different wallpapers (size and settings) on 2 different monitors. The million dollar question: how can I do this in code? One idea I had was to somehow hook into the process that windows uses to draw wallpaper, but I can't find where to make that connection. At this point I'm really not interested in a 3rd party tool that does this, I want to code it myself - I just need a starting point (win32 hook, etc). Thanks!
Advertisement
Desktop has window handle 0. You can use GetDC function to obtain handle to its device context and draw to it as usual. Of course you will need to watch for messages and repaint if necessary.
Cram the two wall-papers together into 1 bitmap and set it as the background.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Quote:Original post by Shannon Barber
Cram the two wall-papers together into 1 bitmap and set it as the background.

That was a million dollar answer. [smile]

I won't be the one paying, though. [wink]
- blew
This might help, Introduction to Display Drivers, maybe the link to the CUJ article too.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Why not just use the multi-monitor api calls to find the rects for the given monitors and then plop a bottom-most window at said locations. To make sure they stay bottom-most just make the ProgMan window the parent/owner and also handle WM_WINDOWPOSCHANGING. This should work for the Explorer desktop; for other desktops like LS, GeoShell, etc., you'd have to do the same thing for their background window, if any.

For handling changes to how your monitors are arranged, top/bottom instead of side-by-side or whatever, handling WM_SETTINGCHANGE would probably work.

I was thinking about doing this so that I could stretch one big wallpaper across multiple monitors, since Windows seems to want to just duplicate it instead. My favorite wallpaper artist Nuvem has made some killer super-wide wallpapers that I'd love to see done up this way.
Quote:Original post by b2b3
Desktop has window handle 0. You can use GetDC function to obtain handle to its device context and draw to it as usual. Of course you will need to watch for messages and repaint if necessary.


Which messages are the critical ones for the wallpaper? I am also concerned about drawing over desktop icons (which would be a no-no).

Quote:Original post by Shannon Barber
Cram the two wall-papers together into 1 bitmap and set it as the background.


This doesn't work for multi-monitor with different resoultions and dynamic layout, though it does seem to be the most popular answer generally given.

Quote:Original post by Anonymous Poster
Why not just use the multi-monitor api calls to find the rects for the given monitors and then plop a bottom-most window at said locations.


I had considered this for a while, and it *is* part of my plan to grab the window rectangles, but simply laying windows over the desktop introduces numerous problems. First, it covers up desktop icons. Second, many programs grab the desktop window handle for layering their windows - expecting the desktop window will be typically visible - but this approach would cover up the screen.

Quote:Original post by Anonymous Poster
This might help, Introduction to Display Drivers, maybe the link to the CUJ article too.


Thanks for the link, this will take a while to digest, and it isn't immediately clear if I'll be able to use this information to accomplish my goal, but it looks very interesting anyway.

Thanks to all who have responded so far! Rating+ for the help.
Quote:Original post by Steven Hansen

I had considered this for a while, and it *is* part of my plan to grab the window rectangles, but simply laying windows over the desktop introduces numerous problems. First, it covers up desktop icons. Second, many programs grab the desktop window handle for layering their windows - expecting the desktop window will be typically visible - but this approach would cover up the screen.


All very good points that I hadn't considered Steve. I don't know if the "grab the desktop window handle" problem applies to my technique since my idea was to put the app's window in-between the listview and shellview windows.

I went ahead and coded up a proof of concept and it's working great for me. Probably because the desktop apps I use are all mine and they're all coded as layered, alpha-blend-to-desktop windows. Anyway, thanks for the idea. Since I haven't had icons on my desktops for years (and normally don't use an Explorer desktop anyway) I'm very happy.

I also tried various ways to get the icons to show up. The best luck I've had so far is to make the window transparent. The icons show up then but Explorer doesn't draw the pixels around them using my window's pixels. It looks like it's using a PaintDesktop call instead.

Hooking into the explorer process and playing a few games there has yielded no better results either. I tried making the listview a child of my window, which ended up killing the listview. Subclassing the shellview window to get it to not draw didn't make any difference as well.

It's all kinda weird because technically it should work, as the listview window is sitting above my window and I've told the listview to use CLR_NONE as its background color and to not use a background image, which in any other listview window means it only draws the icons. And I've done so within the address space of the thread that owns the listview. And it's not being subclassed. So it should only be drawing the icons. But it's not.

Oh well, I'll keep trying now and then, assuming I can think up something else to try, and let you know if I have any better luck.

Also, I'd be more than happy to send you a copy of my app to use for whatever. Just say so here and I'll PM you to either get your email or give you mine.
heh. http://www.realtimesoft.com/multimon/faq.asp
Hmm... That active web page may solve the problem locally.

I would still like to intercept the code that draws the wallpaper though. There are all kinds of interesting ideas for cool animated wallpapers. [smile]

Thanks for the link.

This topic is closed to new replies.

Advertisement