Search code examples
c#windowswinapihandle

C# Set Window Behind Desktop Icons


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?


Solution

  • 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.