views:

508

answers:

2

Hi all. Assume i have an empty form 100px by 100px at 0,0 coordinates on the screen. It has no border style. Is there any way to have this positioned BEHIND the desktop icons?

I would assume this would involve the process Progman because thats what contains the desktop icons. But no matter what i try... getting window handles and changing parents etc, i cant seem to get the window to appear behind the icons.

Any ideas?

+1  A: 

Google-fu led me to this MSDN forum question:

http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/c61d0705-d9ec-436a-b0a6-6ffa0ecec0cc

And this is a blog post regard the major pitfalls with using GetDesktopWindow() or dealing with the desktop handle (as per your other question: http://stackoverflow.com/questions/1966229/c-position-window-on-desktop)

http://blogs.msdn.com/oldnewthing/archive/2004/02/24/79212.aspx

You also don't want to pass GetDesktopWindow() as your hwndParent. If you create a child window whose parent is GetDesktopWindow(), your window is now glued to the desktop window. If your window then calls something like MessageBox(), well that's a modal dialog, and then the rules above kick in and the desktop gets disabled and the machine is toast.

Anyway, I suspect that it probably CAN be done, but whether you should is another question.

Alastair Pitts
the reason i want to do it is so i can create a widget system on my pc. There are somethings that rainmeter just cannot do well
Ozzy
+1  A: 

Essentially you want to draw on the desktop wallpaper. The desktop hierarchy looks like this:

"Program Manager" Progman
  "" SHELLDLL_DefView
    "FolderView" SysListView32

It's the SysListView32 that actually draws the desktop icons, so that's what you have to hook. And you can't just stick your form on top of it; you have to grab a WindowDC to that handle and draw on the DC.

It can be done - it has been done, but you're going to be using a lot of interop. Forget about doing this with a traditional Winforms Form. I don't think I've even seen it done in C#, although somebody did it in python, if that helps. I'm not a python coder myself, but the code is pretty short and easy to understand.

Aaronaught
Hey, I'm that somebody who did it in Python! ;) (saw web traffic coming to my blog from this link... just so happens I'm an SO member too, heh.)
FogleBird