Page 1 of 1
[SOLVED] ScrollAreaGadget and DialogXML
Posted: Sun Jan 07, 2024 10:51 pm
by boddhi
Hi,
Does anyone know how to manage on-the-fly the dimensions of a ScrollAreaGadget created using the DialogXML lib?
This ScrollAreaGadget can contain from one to several thousand ImageGadgets, which can be added or deleted on the fly.
Thanks.
Re: ScrollAreaGadget and DialogXML
Posted: Mon Jan 08, 2024 6:59 pm
by spikey
You can change the internal dimensions using SetGadgetAttribute just as usual. The trick is obtaining the right gadget number. You can either use Runtime constants to specify gadget numbers, see the Multibox example in the
OpenXMLDialog help article. Or you can use the 'name' attribute and use
DialogGadget to obtain a number at runtime:
Code: Select all
#Dialog = 0
#Xml = 0
Runtime Procedure OnButton1Event()
Define.i Scroll1, W, H
Scroll1 = DialogGadget(#Dialog, "Scroll1")
W = GetGadgetAttribute(Scroll1, #PB_ScrollArea_InnerWidth)
H = GetGadgetAttribute(Scroll1, #PB_ScrollArea_InnerHeight)
W + 200
H + 200
SetGadgetAttribute(Scroll1, #PB_ScrollArea_InnerWidth, W)
SetGadgetAttribute(Scroll1, #PB_ScrollArea_InnerHeight, H)
EndProcedure
XML$ = "<window id='#PB_Any' name='test' text='test' width='400' height='400' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
" <vbox expand='item:1'>" +
" <scrollarea id='#PB_Any' name='Scroll1' scrolling='both' innerheight='500' innerwidth='500' />" +
" <button id='#PB_Any' name='Button1' text='Enlarge' onevent='OnButton1Event()'/>" +
" </vbox>" +
"</window>"
If ParseXML(#Xml, XML$) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
Re: ScrollAreaGadget and DialogXML
Posted: Mon Jan 08, 2024 9:48 pm
by boddhi
Hi spikey,
spikey wrote:
You can change the internal dimensions using SetGadgetAttribute just as usual.
Damn ! Why didn't I remember that?
I remained focused and blinded by ResizeGadget as the only solution.
F1 is really a magic key !!!
Thanks a lot
