[Windows] Some fun with drawing on the desktop

BlitzMax Forums/BlitzMax Programming/[Windows] Some fun with drawing on the desktop

grable(Posted 2017) [#1]
After the thread in General Help by Mainswhorty, about drawing to desktop i found this: https://www.codeproject.com/articles/856020/draw-behind-desktop-icons-in-windows

The code there deals with drawing BEHIND the desktop icons, and was quite fun working out.
Im posting it here for future reference and for others to have fun with as well :)

Drawing using GDI, only works in Windows 8+. Though maybe one can draw directly to the shell window instead of the worker?


Drawing using Max2D and a seperate window, works in Windows 8+ but check further down for code to make it work on Windows 7:



GW(Posted 2017) [#2]
Doesn't work for me. win7 pro. the exception is thrown.


grable(Posted 2017) [#3]
Ah yes, i forgot to add, this works for Win 8+, same as the article.
To get it to work for Windows 7, you would have to change the enumeration proc, i think you can change "SHELLDLL_DefView" to "SysListView32".
I dont have Windows 7 so am unable to test myself, but you can read the article and then try something like WinSpy to check the window relations.


grable(Posted 2017) [#4]
There is a comment in that article which mentions how to do it for Windows 7, could work for the second example:

- Create the second WorkerW with the hidden user message as described here.
- Hide this new WorkerW that you just created with ShowWindow().
- Create your new custom window, that you want to draw behind the desktop icons, as a child of Progman.



But again, the relationship between windows is different, so a change to the enumeration proc still has to be made so one can find the WorkerW window.

EDIT: Progman is the Shell window btw.

EDIT2: Had a friend with Windows 7 test for me, for the second example:
Change
SetParent( hwnd, workerw)
to
SetParent( hwnd, GetShellWindow())
ShowWindow( workerw, False)



BlitzSupport(Posted 2017) [#5]
Yeah, EDIT2 works here on '7, pretty cool. Opens a huge ugly window to start with, but I imagine that could be hidden with a little hackery...


grable(Posted 2017) [#6]
Yeah, the reason for that is because its using a Graphics window. And it is created AND shown before the changes are made to it, making it flicker (on slower computers anyway, i dont see it :p)

Theres no way around this without modifying the Max2D backends im afraid.
Using MaxGUI though, you can create the window hidden then show it after the changes, which works.