TreeGadget resizing

Windows specific forum
Machiavelli
User
User
Posts: 26
Joined: Sun May 24, 2009 2:38 pm

TreeGadget resizing

Post by Machiavelli »

Hello

I have a window with one TreeGadget on the left, second TreeGadget on the right, and the PanelGadget between them (so i can't use splittergadget)
Is there any way to make treegadgets resizeable with mouse? (only horizontally)
I've tried to detect mouse clicks over the edge of the gadget and then resizing it but it didn't really work.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: TreeGadget resizing

Post by RASHAD »

No you can use SplitterGadget

Code: Select all

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered
OpenWindow(0,0,0,600,400,"Test",Flags)
cont = ContainerGadget(#PB_Any,10,10,580,380,#PB_Container_Flat)
  tree1 = TreeGadget(#PB_Any,0,0,0,0)
  For a = 0 To 100
   AddGadgetItem(tree1, -1, "Elément normal "+Str(a), 0, 0)
  Next
  panel = PanelGadget(#PB_Any,0,0,0,0)  
    AddGadgetItem (panel, -1, "Panel 1")
  CloseGadgetList()
  split = SplitterGadget(#PB_Any,0,0,580,380,tree1,panel, #PB_Splitter_Separator|#PB_Splitter_Vertical )  
CloseGadgetList()
SetGadgetState(split, 200)
tree2 = TreeGadget(#PB_Any,0,0,0,0)
For a = 0 To 100
 AddGadgetItem(tree2, -1, "Elément normal "+Str(a), 0, 0)
Next
split2 = SplitterGadget(#PB_Any,10,10,580,380,cont,tree2, #PB_Splitter_Separator|#PB_Splitter_Vertical )
SetGadgetState(split2, 400)   

Repeat
           
  Select WaitWindowEvent()      
    Case #PB_Event_CloseWindow
        Quit = 1
  EndSelect
Until Quit = 1
End
Edit :Modified
Last edited by RASHAD on Tue Oct 10, 2017 3:06 pm, edited 1 time in total.
Egypt my love
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: TreeGadget resizing

Post by spikey »

If you don't want to use two splitters, as Rashad shows, then you could also:-

1) Use a canvas gadget as a container and process the #PB_EventType_LeftButtonDown and #PB_EventType_LeftButtonUp events.
2) Use a window callback procedure to process the #WM_LBUTTONDOWN and #WM_LBUTTONUP messages.

In either case you would need to range test the X and Y co-ordinates to determine which gap had been clicked in the button down and the new gadget dimensions in the button up.
Post Reply