Canvas as parent for other gadgets...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Canvas as parent for other gadgets...

Post by Joris »

Hi,

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
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Canvas as parent for other gadgets...

Post by IdeasVacuum »

...or #PB_Container

+1
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuckyLuke
Enthusiast
Enthusiast
Posts: 181
Joined: Fri Jun 06, 2003 2:41 pm
Location: Belgium

Re: Canvas as parent for other gadgets...

Post by LuckyLuke »

+1

LuckyLuke
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Canvas as parent for other gadgets...

Post by Justin »

I requested this a year ago maybe.
Anyways +1
Post Reply