Code: Select all
Enumeration
#Win
#Img
#ImageGdt
#Cntr
#BtnBox
#BtnExit
EndEnumeration
Global igTrans = RGBA(128,128,000,000) ;Transparent
Global igOpaque = RGBA(128,128,000,255)
Procedure Win()
;--------------
Protected iExit.i = #False
Protected iFlags.i = #PB_Container_BorderLess | #PB_Container_Flat
If OpenWindow(#Win, 0, 0, 800, 600, "", #PB_Window_ScreenCentered)
SetWindowLongPtr_(WindowID(#Win), #GWL_EXSTYLE, #WS_EX_LAYERED)
SetLayeredWindowAttributes_(WindowID(#Win), igTrans, 0, #LWA_COLORKEY)
CreateImage(#Img, 800, 550, 32, igOpaque)
ImageGadget(#ImageGdt, 0, 50, 800, 550, ImageID(#Img))
ContainerGadget(#Cntr, 0, 0, 800, 50, iFlags)
ButtonGadget(#BtnBox, 2, 2, 100, 26, "Draw Boxes")
ButtonGadget(#BtnExit, 105, 2, 100, 26, "Exit")
SetGadgetColor(#Cntr, #PB_Gadget_BackColor, RGB(096,096,096))
CloseGadgetList()
StickyWindow(#Win, #True)
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_Gadget
Select EventGadget()
Case #BtnExit: iExit = #True
Case #BtnBox
If StartDrawing(ImageOutput(#Img))
Box(150,100,100,100,RGB(Random(255),Random(255),Random(255)))
Box(250,200,100,100,RGB(Random(255),Random(255),Random(255)))
Box(300,300,100,100,RGB(Random(255),Random(255),Random(255)))
Box(450,100,100,100,RGB(Random(255),Random(255),Random(255)))
Box(350,200,100,100,RGB(Random(255),Random(255),Random(255)))
StopDrawing()
EndIf
SetGadgetState(#ImageGdt,ImageID(#Img))
EndSelect
EndSelect
Until iExit = #True
EndIf
EndProcedure
Win()
End

