RefreshDialog() doesn't work

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

RefreshDialog() doesn't work

Post by Lord »

Example:

Code: Select all

EnableExplicit

Runtime Enumeration
  #MainWindow = 1
EndEnumeration
Runtime Enumeration
  #Button1
  #Text1
  #Editor1
  #Progressbar
EndEnumeration

Define.i xmlGUI, dlgGUI, i
Define XML$, LF25.s

LF25=RSet("", 25, #LF$)

Procedure DeleteProgressbar()
  Shared dlgGUI
  If IsGadget(#Progressbar)
    FreeGadget(#Progressbar)
    SetGadgetItemText(#Editor1, 25, "Gadget does not expand"+#CRLF$+" \/  \/  \/  \/  \/  \/  \/  \/")
  EndIf
  RefreshDialog(dlgGUI)
  SetGadgetItemText(#Editor1, 2, "Gadget height after refresh: "+GadgetHeight(#Editor1))
EndProcedure

XML$="<?xml version='1.0' encoding='UTF-8'?>"+
     "<dialogs>"+
     "  <window ID='#MainWindow' text='Test 2' name='myWindow'"+
     "          minwidth='640' minheight='480'"+
     "          flags='#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered |"+
     "                 #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget'>"+
     "  <vbox expand='item:2'>"+
     "    <hbox expand='item:2'>"+
     "      <button ID='#Button1' width='12' height='12' text='X'>"+
     "      </button>"+
     "      <text ID='#Text1' height='12' text='- Delete progressbar and refresh dialog'>"+
     "      </text>"+
     "    </hbox>"+
     "    <editor ID='#Editor1' >"+
     "    </editor>"+
     "    <progressbar ID='#Progressbar' height='8' min='0' max='100'>"+
     "    </progressbar>"+
     "  </vbox>"+
     "  </window>"+
     "</dialogs>"

xmlGUI = ParseXML(#PB_Any, XML$)
If xmlGUI
  If XMLStatus(xmlGUI) = #PB_XML_Success
    dlgGUI = CreateDialog(#PB_Any)
    If dlgGUI
      If OpenXMLDialog(dlgGUI, xmlGUI, "myWindow")
        BindGadgetEvent(#Button1, @DeleteProgressbar())
        SetGadgetText(#Editor1, LF25)
        SetGadgetItemText(#Editor1, 1, "Gadget height prior refresh: "+GadgetHeight(#Editor1))
        SetGadgetItemText(#Editor1, 25, " \/  \/  \/  \/  \/  \/  \/  \/")
        
        Repeat
        Until WaitWindowEvent()=#PB_Event_CloseWindow
        
      Else
        Debug "Error in dialog definition: " + DialogError(dlgGUI)
      EndIf
    Else
      Debug "Dialog could not be created!"
    EndIf
  Else
    Debug "XML error: " + XMLError(xmlGUI)
    Debug "           in line " + Str(XMLErrorLine(xmlGUI)) + " at position " + Str(XMLErrorPosition(xmlGUI))
  EndIf
  FreeXML(xmlGUI)
Else
  Debug "XML could not be catched from memory."
  End
EndIf
Image
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: RefreshDialog() doesn't work

Post by Fred »

Unfortunately you can't remove a gadget without informing the dialog manager. It should have new command like FreeDialogGadget() or something similar. Moved to feature and request.
Post Reply