Code: Select all
Procedure TransparentCanvas( canvas )
If StartDrawing(CanvasOutput(canvas))
FillMemory( DrawingBuffer(), DrawingBufferPitch() * OutputHeight())
StopDrawing()
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 220, 220, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0, $FFC8ECF0)
CanvasGadget(0, 10, 10, 200, 200, #PB_Canvas_Container)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
CloseGadgetList()
TransparentCanvas(0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
Circle(x, y, 10, RGBA(Random(255), Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
Case 1
TransparentCanvas(0)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
for windows
Code: Select all
Procedure Clip( gadget )
GadgetID = GadgetID(gadget)
SetWindowLongPtr_( GadgetID, #GWL_STYLE, GetWindowLongPtr_( GadgetID, #GWL_STYLE ) | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN )
SetWindowPos_( GadgetID, #HWND_TOP, 0,0,0,0, #SWP_NOMOVE | #SWP_NOSIZE )
EndProcedure
Procedure TransparentCanvas( canvas )
RedrawWindow_(GetAncestor_( GadgetID(canvas), #GA_ROOT ), #Null, #Null, #RDW_INVALIDATE | #RDW_ERASENOW | #RDW_ALLCHILDREN | #RDW_UPDATENOW)
EndProcedure
If OpenWindow(0, 0, 0, 220, 220, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 220, 220)
;Clip(0)
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE) | #WS_EX_LAYERED)
SetLayeredWindowAttributes_(GadgetID(0), #White, 1, #LWA_ALPHA)
;\\
gadget = TextGadget(-1, 0, 0, 220, 220, "")
Clip(gadget)
;SetWindowColor(0, $C8ECF0)
SetGadgetColor(gadget, #PB_Gadget_BackColor, $C8ECF0)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
Clip(1)
TransparentCanvas(0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
Circle(x, y, 10, RGBA(Random(255), Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
Case 1
TransparentCanvas(0)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf