is there a way to draw on the desktop with no window,and transparency

Community Forums/General Help/is there a way to draw on the desktop with no window,and transparency

Mainsworthy(Posted 2017) [#1]
is there a way to draw on the desktop with no window,and transparency? Ive been looking for some way, and I'm stumped, so I throw it to you guys who know more than most about programing.


grable(Posted 2017) [#2]
You would have to go the GDI route for that. Using GetDC(GetDesktopWindow()) to get a drawing context and go from there.
Whatever you draw will get overwritten the moment the window is updated though, so either use a thread (bad) or hook the window procedure and do the drawing when requested (better).
Using GDI to draw isnt exactly fun, and transparency isnt supported by most calls, but there is AlphaBlend which should work.

EDIT: Forgot to add, the above is for Windows. Dunno about linux.


Matty(Posted 2017) [#3]
Yes in blitzplus I believe there is. You can capture the desktopbuffer and draw to that but it will be a static screenshot of the current desktop.


Mainsworthy(Posted 2017) [#4]
thanks guys, I'm on the right track atleast.


Mainsworthy(Posted 2017) [#5]


https://numbergamer8.itch.io/template-app-for-boardgames-on-a-pc

grable, I put you in the credits, because I used some code from the code archive of yours, I did lots to it, but you gave me the start I needed thanks

. its a boardgame tool, it allows you to measure on a tv or monitor , things you need to know in boardgames an miniatures. it pastes a template on the screen that you can rotate of any shape, so imagine Warhammer where you need to know who was in the blast area, you would use a circle, what makes this worth doing is it works with vassal.


grable(Posted 2017) [#6]
Im glad you figured it out, layered windows is much easier to work with so i can understand why you chose it instead of drawing directly on the desktop.

I actually tried myself with overriding the windowproc but i keep forgetting blitz is 32bit while windows components are 64bit, bad match hehe. No matter, i probably need to DLL inject some code anyway which makes this more than just toying around...

grable, I put you in the credits, because I used some code from the code archive of yours, I did lots to it, but you gave me the start I needed thanks
Never been in any ones credits before, thanks :D


Mainsworthy(Posted 2017) [#7]
I found info that you had to do a DLL for windows , and when windows updates etc.. its nogood anymore, I guess windows don't want us messing, also people that had done it were saying you have junk added, so I relied on your code a a base line, and I'm very happy, credit where credit is due thankyou


grable(Posted 2017) [#8]
May i ask what junk they were talking about? If you mean [MaxGUI/Win32]: Transparent Window Gadgets, it looks pretty clean to me, for what it was designed for anyway (MaxGUI).


Mainsworthy(Posted 2017) [#9]
no not this stuff, they said when they draw to the windows desktop they got junk added, They never used MaxGUI I don't think etc.. it was a generals comments about borderless windowless transparent drawing direct to desktop. I'm not as wise as you , and Ive ony been at this a short time, so I know you know better than me


grable(Posted 2017) [#10]
Ah my mistake, no worries :)

Yeah, drawing to the desktop does cause "junk" so to say. Without also having control over the painting process, two entities end up fighting over when to draw what, causing artifacts.


Dan(Posted 2017) [#11]
Autoit Script can draw transparent windows:

Dragable transparent gif image, in autoIt

Maybe someone can write something similar, for Blitz +,3d,max ?

p.s. the example from the link is trying to download a gif file, from a server, but its allready deleted.

here is the AutoIt code which loads local gif file, called Transparent_gif.gif




Mainsworthy(Posted 2017) [#12]
very interesting Dan, thanks for this info,


Mainsworthy(Posted 2017) [#13]
Dan, I grabed autoit, its free :) and did a compile, the big script you have isn't nessasary

here is the one that seems to do same thing, but I think animated. just add a gify.gif size 100x100 in your scripts folder.

they don't rotate, but its definatly worth looking at, and there are plenty of scripts even rotating to trawl thrugh, also it draws on the desktop, good find





#include <GUIConstants.au3>

$src = "gify.gif"
$dest = @ScriptDir & "\gify.gif"
InetGet($src,$dest)

$width = 100
$height = 100
$gui = GUICreate("GUI Transparency", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$pic = GUICtrlCreatePic($dest, 0, 0, $width, $height,-1,$GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)
WinSetOnTop($gui, "",1)
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


grable(Posted 2017) [#14]
I dont know what that AutoIt script looks like, but im guessing it does something similar to the below?

This one was not fun to figure out :( Im usually quite fond of MSDN but this time it lied to me, making me waste a lot of time :(
It seems the optional arguments to UpdateLayeredWindow are NOT optional after all hrmph.

Note that this ONLY displays the image supplied, though all the controls are still there and clickable.
And if you need rotation, you could pre-rotate the image to a bunch of them and switch between them when neeeded.

Also, this technique is only worthwhile if you need per-pixel alpha, otherwise the standard layered windows are much easier.

(press ESC or click the center to exit cleanly)

And heres the image i used for testing: coca.png

EDIT: See Layered window per-pixel alpha + Max2D for a more advanced example.


Dan(Posted 2017) [#15]
Iv just uploaded a Screen Mate/Desktop pets program on Emu.Zone

It uses GDI+ to display the Sprites on the screen, they are drag'able, with transparent background and self moving.

The Sourcecode is in AutoIt script, and is included in the download.

Maybe it can be usefull, as it shows how it is done in the function SetBitmap.