I assume you'd like to use PureBasic drawing commands to draw to the desktop. This can be accomplished in a straightforward and easy way with just a couple of API calls. Here is the method:
1. Create a transparent image to serve as the drawing surface
2. Draw whatever you like to this surface
3. Open a borderless window to host the surface
4. Apply the 'Layered' extended style to the window
5. Blit the image to the window
5. If desired, provide the ability to move the image around on the desktop or close it
Code Example:
Code: Select all
; Another entry in an endless string of useless programs by netmaestro
CreateImage(0,320,320,32,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(0))
VectorSourceColor(RGBA(255,0,0,255))
AddPathCircle(120,120, 70)
StrokePath(6)
VectorSourceColor(RGBA(0,0,255,255))
AddPathBox(120,80,100,80)
StrokePath(6)
VectorSourceColor(RGBA(0,0,255,60))
AddPathCircle(120,120,68,-38,38)
AddPathBox(120,80,57,80)
FillPath(#PB_Path_Winding)
StopVectorDrawing()
Procedure BlitWindow(window, image)
hDC = StartDrawing(ImageOutput(image))
With sz.SIZE
\cx = ImageWidth(image)
\cy = ImageHeight(image)
EndWith
With BlendMode.BLENDFUNCTION
\SourceConstantAlpha = 255
\AlphaFormat = 1
EndWith
UpdateLayeredWindow_(WindowID(window),0,0,@sz,hDC,@ContextOffset.POINT,0,@BlendMode,2)
StopDrawing()
EndProcedure
OpenWindow(0,0,0,320,320,"Gdiplus Drawing",#PB_Window_ScreenCentered|#PB_Window_BorderLess)
SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, #WS_EX_LAYERED)
CreatePopupMenu(0)
MenuItem(9, "Exit")
BlitWindow(0, 0)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #WM_LBUTTONDOWN
SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
Case #PB_Event_Menu
If EventMenu()=9 : End : EndIf
Case #WM_RBUTTONDOWN
DisplayPopupMenu(0, WindowID(0))
EndSelect
Until EventID = #PB_Event_CloseWindow
Remember, everything in the Windows Operating System is a window. If you use a window for your output it will be persistent and well-behaved on your desktop. Trying to draw directly to the desktop without using a window is folly. It would be like running into a grocery store, grabbing an item off the checkout counter and running like hell. It just goes against all of the structure and order of things.