Edit a dialog vbox/hbox at runtime

Just starting out? Need help? Post your questions and find answers here.
atomo
User
User
Posts: 65
Joined: Thu May 22, 2008 10:32 pm

Edit a dialog vbox/hbox at runtime

Post by atomo »

Hi,

Is it possible to add gadgets inside a dialog vbox/hbox after OpenXMLDialog has been called ?
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2139
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Edit a dialog vbox/hbox at runtime

Post by Andre »

Unfortunately I think not.

It would be a dream, if you could easily do an 'update' to a dialog window, after it's content (more or less gadgets, the content of multi-line gadgets like listicons, textgadgets etc.) or it's font size has changed.

Several similar requests have been made, see here: http://www.purebasic.fr/english/search. ... mit=Search
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Edit a dialog vbox/hbox at runtime

Post by RASHAD »

Hi
I am not sure if the next snippet do the job or not
- Click OK to add a new Gadget
- Click Cancel to get the response from the new one

Code: Select all

CompilerIf #PB_Compiler_Unicode
  #XmlEncoding = #PB_UTF8
CompilerElse
  #XmlEncoding = #PB_Ascii
CompilerEndIf

XML$ = "<?xml version='1.0' ?>"+
       " <window id='0' name='test' text='Gridbox' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "  <hbox expand='item:3'>" +
       "    <button text='OK' height='40' width='80' id='10'/>"+
       "    <button text='Cancel' height='40' width='80' id='11'/>"+
       "    <empty/>"+
       "    <image name='fixedImage' height='40' width='40' />"+
       "  </hbox>"+
       " </window>"

Define XML.i
Define Dialog.i

XML.i = CatchXML(#PB_Any, @XML$, StringByteLength(XML$), 0, #XmlEncoding)
Dialog.i = CreateDialog(#PB_Any)
OpenXMLDialog(Dialog.i, XML.i, "test")

Define Image.i = CreateImage(#PB_Any, 40, 40)
StartDrawing(ImageOutput(Image.i))
Box(0,0,40,40, RGB(255,255,255))
Circle(20,20,17, RGB(255,0,0))
StopDrawing()
SetGadgetState(DialogGadget(Dialog.i, "fixedImage"), ImageID(Image.i))

Repeat
  Select WaitWindowEvent()
       Case #PB_Event_CloseWindow
              Quit =1
       Case #PB_Event_Gadget
              Select EventGadget()
                    Case 10
                           ;*************** Simple Add ****************************************
                           ;ResizeWindow(0,#PB_Ignore ,#PB_Ignore ,WindowWidth(0)+60,#PB_Ignore )
                           ;ButtonGadget(12,GadgetX(10)+170,GadgetY(10),60,40,"Button 12")
                           
                           ;***************  Keeping The Dialogue Properties **********************
                           FreeDialog(Dialog.i)
                           XML2$ = "<?xml version='1.0' ?>"+
                           " <window id='0' name='test' text='Gridbox' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
                           "  <hbox expand='item:4'>" +
                           "    <button text='OK' height='40' width='80' id='10'/>"+
                           "    <button text='NO' height='40' width='80' id='11'/>"+
                           "    <button text='Cancel' height='40' width='80' id='12'/>"+
                           "    <empty/>"+
                           "    <image name='fixedImage' height='40' width='40' />"+
                           "  </hbox>"+
                           " </window>"
                           XML.i = CatchXML(#PB_Any, @XML2$, StringByteLength(XML2$), 0, #XmlEncoding)                           
                           Dialog.i = CreateDialog(#PB_Any)
                           OpenXMLDialog(Dialog.i, XML.i, "test")
                           SetGadgetState(DialogGadget(Dialog.i, "fixedImage"), ImageID(Image.i))
                           
                    Case 12
                            Debug "Cancel"
              EndSelect
  EndSelect                  
Until Quit =1 
CloseWindow(DialogWindow(Dialog.i))

End
Egypt my love
Post Reply