• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

How to place a form or canvas behind the win icons?


I'm quite desperatly seeking a way to draw on the desktop while the win icons (and other apps) remain the same.

If you'd like to see an example please take a look at: http://www.geisswerks.com/drempels/ (desktop mode) which is an excellent tiny tool, btw. So as you see I'm not talking about a static wallpaper, rather a dynamic one ;)

I have tried to use sendtoback(); with my app but that simply puts the Tform behind all others. The windows icons are still further behind, the desktop even more.

I'd like to have my form behind the icons and in front of the desktop :)

Any ideas?

Thanks, triton
1 Solution
I think you have to subclass the desktop listview control by calling SetWindowLong(desktopListViewHandle, GWL_WNDPROC). Unfortunately this works only if you're inside of the explorer process. To achieve that, you need to put your stuff into a little dll and make sure that the dll is loaded into the explorer. You can misuse SetWindowsHookEx by creating a dummy message hook to do that.

Regards, Madshi.
Better yet, use the features of the active desktop & write it in html instead.

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

maybe you don't need to draw _behind_ the desktop ... you could do something like fake that you are drawing behind the desktop icons with making a screenshot of the current desktop and set all exept the icons to transparent, this transparent picture of the desktop you paint above the canvas you are painting on and it will look like if you are painting behind the icons.
to get a transparent image of the desktop you could replace the wallpaper with just a single color (one that is not very often used in icons would be best) than take the screenshot and set the background color to transparent. Before doing that remember what the wallpaper was before so you can restore it.
Now all should be ready for your drawing ...

this is just a brain experiment, I never did something like this, I was just thinking of a way how this could be achieved.

Please elaborate on the use of SetWindowsHookEx to trick
Explorer into loading me into memory

If you can use Mike's solution (ActiveDesktop), it's surely the better way, because it's clean and documented.

About SetWindowsHookEx:
(1) Get the desktop list view handle ("wnd := FindWindowEx(FindWindowEx(windows.FindWindow('Progman', 'Program Manager'), 0, 'SHELLDLL_DefView',''), 0, 'SysListView32', '');").
(2) Call GetWindowThreadProcessID to get the threadID to which the desktop list view belongs.
(3) Call SetWindowsHookEx(WH_GETMESSAGE, @DummyHookProc, YourDllHandle, ThreadIDFromStep2) to install a dummy message hook. The "DummyHookProc" callback function must be located in a little dll.
(4) Now call PostMessage(desktopListViewHandle, WM_NULL, 0, 0). As a result Windows will load your dll into the context of the thread which owns the desktop list view and calls your message callback function there.
(5) Now in the dll you can subclass the desktop list view.

Regards, Madshi.

P.S: There's also an easier method of injecting a dll into a different process without needing this nasty SetWindowsHookEx hack. It's documented here (see the very bottom of the page):


The packages described there are free for non-commercial usage.
triton090898Author Commented:

thanks folks. But I think we've got a prob here ;)
Houston? :)))

I won't be able to hook my code onto another process. And I won't be able to snapshot the icons to pretend they're still there.

Just take a look at the page http://www.geisswerks.com/drempels/ and you'll see.
If you install that 500kb boy ;) simply tell it to use 'desktop mode'. It'll blow you away. W9x & W2k.

With that tiny tool you have a full screensaver running on your pc all the time, but you can still use the entire icon, window and startmenu functionality, because they're still visible. Once again: everything is still usable.

So there must be a way to render/draw on the desktop object. ActiveX has nothing to do with it, it actually has to be deactivated for this.

Any more ideas?

triton ;)
triton090898Author Commented:
**** ;)

Of course ActiveDesktop has to be deactivated, not ActiveX :)))

;) triton
Hello, here is Houston.

Drempels uses an alternative method: It changes the background image of the desktop to none and the background color to pink, which is the default video overlay color. Then it uses video overlay functionality to draw. The effect is that Drempels not only draws on the desktop background, but only on every other pixel on the screen, which is pink. If you open a jpeg foto in Photoshop, and there are pink pixels in it, these pixels will also be overdrawn by Drempels. Furthermore not every graphics card (but almost every) supports video overlay. I don't know how to do video overlay programming, if you want to go this way, I'm out of this question...

Regards, Madshi.
triton090898Author Commented:
Hi Madshi,

that was what I wanted to hear. I have two friends, one doing www.openuniverse.org, another doing www.shatters.net/celestia (you'll love it).

I hope you don't mind if we contact you in case we have a few further questions you can answer?

Thanks in Advance, triton ;)
Thanx for the points...

If the further questions belong to this thread, please ask them directly here, so the others can participate. Otherwise please post a new question in Experts-Exchange. I'm always looking for new questions in EE. You can post a link to your new question(s) here, just to be sure that I don't miss the new questions(s).

Regards, Madshi.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now