Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 627
Ozzy Avatar asked Dec 30 '09 02:12

Ozzy


2 Answers

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.

like image 186
Aaronaught Avatar answered Sep 24 '22 13:09

Aaronaught


There is a solution to this problem, at least for Windows 8. I postet it in form of an article on CodeProject, so you can read about it here:

http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows

This works for simple drawing, windows forms, wpf, directx, etc. The solution presented in that article is only for Windows 8.

like image 38
Gerald Degeneve Avatar answered Sep 22 '22 13:09

Gerald Degeneve