Useful for drawing/rendering on the Desktop (behind the Icons) Wallpaper Style.
Nothing more nothing less.
Update 25.11.2023 - Version 1.02:
- Fixed a small bug in \Link() & \Unlink
- \Size() now optionally returns the size of the primary monitor
Update 24.11.2023 - Version 1.01:
- Improved the code
- Fixed a bug in \Update()
- Added \Event() to help processing events (optional)
Update 23.11.2023 - Version 1.00:
Rcoded the library in FASM (its a static lib now), i also changed the license.
All code examples outside this post may need to be adapted as some functions have been renamed/changed!
The include v.1.02:
Code: Select all
EnableExplicit
;--------------------------------------------------------------------------------------
; DSKT Library
; Written in FASM 1.73.30
;--------------------------------------------------------------------------------------
; Version: 1.02
; Author: Mijikai
; Platform: Windows x64
;--------------------------------------------------------------------------------------
; Copyright 2022 - 2023 by Mijikai all rights reserved
;--------------------------------------------------------------------------------------
; License:
; CC BY-ND 4.0 DEED Attribution-NoDerivs 4.0 International:
; https://creativecommons.org/licenses/by-nd/4.0/
;--------------------------------------------------------------------------------------
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
;--------------------------------------------------------------------------------------
Import "dskt.lib"
dsktInterface.i()
dsktVersion.i()
EndImport
Interface DSKT
Handle.i() ;returns the handle to a desktop window (behind the icons)
Size.i(*Width,*Height,Flag.i = #False) ;get the width and height of the desktop window, if the flag is #True the size of the primary monitor / returns #True or #False
Link.i(Handle.i) ;makes a window a child to the desktop window (only one window!) / returns <> #Null on success
Unlink.i() ;resets all changes to the desktop and/or unlinks a child window / returns #Null
Event.i() ;process events - can be useful when drawing into the desktops device context / returns #Null
Update.i() ;resets everything (call if the desktop was updated or has changed - ex. if the resulution changed) / returns #True or #False
Release.i() ;cleans up and releases the interface / returns #Null
EndInterface
#DSKT_VERSION = $102
Code: Select all
EnableExplicit
XIncludeFile "dskt.pbi"
Procedure.i Main()
Protected *dskt.DSKT
Protected hdc.i
Protected w.i
Protected h.i
Protected r.RECT
If dsktVersion() = #DSKT_VERSION
*dskt = dsktInterface()
If *dskt
*dskt\Size(@w,@h)
Debug w
Debug h
hdc = GetDC_(*dskt\Handle())
If hdc
r\right = w
r\bottom = h
FillRect_(hdc,@r,GetStockObject_(#WHITE_BRUSH))
*dskt\Event()
Delay(5000)
ReleaseDC_(*dskt\Handle(),hdc)
EndIf
*dskt\Release()
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
Code: Select all
EnableExplicit
XIncludeFile "dskt.pbi"
Procedure.i Main()
Protected *dskt.DSKT
Protected w.i
Protected h.i
Protected c.POINT
If dsktVersion() = #DSKT_VERSION
*dskt = dsktInterface()
If *dskt
*dskt\Update()
*dskt\Size(@w,@h)
InitSprite()
If OpenWindowedScreen(*dskt\Handle(),0,0,w,h)
SetFrameRate(60)
If CreateSprite(0,96,96,#PB_Sprite_AlphaBlending)
If StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Circle(48,48,32,$FF0000FF)
StopDrawing()
EndIf
Repeat
GetCursorPos_(@c)
ClearScreen(0)
DisplaySprite(0,c\x - 48,c\y - 48)
FlipBuffers()
*dskt\Event()
ForEver
EndIf
EndIf
*dskt\Release()
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
Code: Select all
EnableExplicit
XIncludeFile "dskt.pbi"
Procedure.s HtmlVideo(Width.i,Height.i,Url.s);http://forums.purebasic.com/english/viewtopic.php?p=509325&sid=ecc20b236c2f4bcd7b445926ac5192c5#p509325
Protected src.s
src + "<html>" + #LF$ + #TAB$ + "<head>" + #LF$ + #TAB$ + #TAB$ + "<style type='text/css'>" + #LF$
src + #TAB$ + #TAB$ + "<style type='text/css'>" + #LF$ + #TAB$ + #TAB$ + #TAB$
src + "body {margin-left: 0px; margin-right:0px; margin-top:0px; margin-bottom:0px; overflow: hidden}" + #LF$
src + #TAB$ + #TAB$ + "</style>" + #LF$ + #TAB$ + "</head>" + #LF$ + #TAB$ + "<body scroll='no'>" + #LF$ + #TAB$ + #TAB$
src + "<iframe width='" + Str(Width) + "' height='" + Str(Height) + "' src='" + Url + "' frameborder='0'></iframe>" + #LF$
src + #TAB$ + "</body>" + #LF$ + "</html>"
ProcedureReturn src
EndProcedure
Procedure.i HtmlGadget(X.i,Y.i,Width.i,Height.i,Url.s);http://forums.purebasic.com/english/viewtopic.php?p=509325&sid=ecc20b236c2f4bcd7b445926ac5192c5#p509325
Protected gadget.i
Protected *iwb2.IWebBrowser2
gadget = WebGadget(#PB_Any,X,Y,Width,Height,#Null$)
If gadget
SetGadgetAttribute(gadget,#PB_Web_BlockPopupMenu,#True)
SetGadgetAttribute(gadget,#PB_Web_BlockPopups,#True)
*iwb2 = GetWindowLongPtr_(GadgetID(gadget),#GWLP_USERDATA)
*iwb2\put_Silent(#True)
SetGadgetItemText(gadget,#PB_Web_HtmlCode,HtmlVideo(Width,Height,Url))
EndIf
ProcedureReturn gadget
EndProcedure
Procedure.i Main()
Protected *dskt.DSKT
Protected w.i
Protected h.i
If dsktVersion() = #DSKT_VERSION
*dskt = dsktInterface()
If *dskt
*dskt\Size(@w,@h)
If OpenWindow(0,0,0,w,h,#Null$,#PB_Window_BorderLess)
SetWindowColor(0,0)
If HtmlGadget(w >> 1 - 540,h >> 1 - 360,1080,720,"https://www.youtube.com/embed/uYfxDF_QR94?autoplay=1&showinfo=0&controls=0&rel=0")
*dskt\Link(WindowID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow Or GetAsyncKeyState_(#VK_ESCAPE) & 1
CloseWindow(0)
EndIf
EndIf
*dskt\Release()
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
End Main()
https://www.dropbox.com/scl/fi/68utl6qg ... klx66&dl=0
Have fun