Besides the code below, I'll explain a bit more why.
For many drawings a canvas is useful, still a canvas can't be used as parent for other gadgets without the sollution made by RASHAD (when I was looking for this kind of setup).
Now that there are more and more drawings possible ("the invasion of toolbar icons") I start to use one big canvas as total background for all drawings on every window,
instead of one for each or a few drawings. Surely when the drawings need to be changed at runtime (more difficult with limited events on other gadgets).
Feature Requests (cross platform) : flag like "#PB_Canvas_As_Parent" whihc does the same like Procedure Change_Canvas_Property().
Thanks.
Code: Select all
Procedure Change_Canvas_Property(index.i) ;made by our beloved RASHAD (of course ;-)
Protected Msg.s=Space(1024)
If #False=SetWindowLongPtr_(GadgetID(index), #GWL_STYLE, GetWindowLongPtr_(GadgetID(index), #GWL_STYLE) | #WS_CLIPSIBLINGS)
FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, @Msg, 1024, 0)
EndIf
If #False=SetWindowPos_(GadgetID(index), #HWND_BOTTOM, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, @Msg, 1024, 0)
EndIf
EndProcedure
Global cnv.i, btn.i, upd.i, Event.i
If OpenWindow(0, 0, 0, 1120, 720, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
cnv=CanvasGadget(#PB_Any, 10, 10, 1100, 700)
btn=ButtonGadget(#PB_Any , 10, 680, 80, 18,"Draw")
upd=ScrollBarGadget(#PB_Any, 10, 660, 40, 18,0, 1,0)
;if you don't use this call you can't use the gadgets upon the canvas.
Change_Canvas_Property(cnv) ;om child object op canvas te kunnen zetten => uitvoeren na plaatsing van alle objecten op de canvas.
;**************************************************
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case cnv :
Case btn : Debug "btn"
Case upd : Debug "upd"
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf