[SOLVED] ScrollAreaGadget and DialogXML

Just starting out? Need help? Post your questions and find answers here.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

[SOLVED] ScrollAreaGadget and DialogXML

Post 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.
Last edited by boddhi on Mon Jan 08, 2024 10:07 pm, edited 1 time in total.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: ScrollAreaGadget and DialogXML

Post 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
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: ScrollAreaGadget and DialogXML

Post by boddhi »

Hi spikey,
spikey wrote: You can change the internal dimensions using SetGadgetAttribute just as usual.
Damn ! Why didn't I remember that? :oops: :oops: :oops:
I remained focused and blinded by ResizeGadget as the only solution. :mrgreen:
F1 is really a magic key !!! :lol:

Thanks a lot :)
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply