Automatic resize with dialog doesn't work?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Automatic resize with dialog doesn't work?

Post by Lord »

Hi!

I'm trying to use the dialog library and again I have
some sort of problem.
Why does a with 'expand' marked part of a window
not expand after its available space has expanded?
I know I can do it manually, but I thought a dialog
would do it by itself in the same manner when the
window is manually resized by the user.
In my example I've got a progressbar below an edi-
tor, which is created with 'expand' set.
When freeing the progressbar, the editor is not using
the freed space.

Code: Select all

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

Procedure ToggleProgressbar()
  If IsGadget(#Progressbar)
    FreeGadget(#Progressbar)
  EndIf
  
EndProcedure

XML$="<?xml version='1.0' encoding='UTF-8'?>"+
     "<dialogs>"+
     "  <window ID='#MainWindow' text='Test' 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='?'>"+
     "      </button>"+
     "      <text ID='#Text1' height='12' text='- Delete progressbar'>"+
     "      </text>"+
     "    </hbox>"+
     "    <editor ID='#Editor1' text='Editor 1'>"+
     "    </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, @ToggleProgressbar())
        
        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
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: Automatic resize with dialog doesn't work?

Post by Lord »

Nobody agrees or disagrees with my observation?
Image
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Automatic resize with dialog doesn't work?

Post by Marc56us »

Lord wrote:Nobody agrees or disagrees with my observation?
I think that despite its qualities, there are very few people who use the dialog library.
One of the main reasons being the tedious side of the XML language.
(12 years of PB and I've never used it: I do everything by myself with internal Form Designer (Even for small resizable interfaces )

That said, wait a few days. No need to do a UP after 2 days.

:wink:
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Automatic resize with dialog doesn't work?

Post by RASHAD »

Hi Lord
I did my best to find any solution but doing it manually as you can do it
But no success
The only afford tech. by PureBasic is RefreshDialog(#Dialog) which will bring you back to the original XML
FYI I did it only manually I mean out of XML by ResizeGadget() but still using code :)
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: Automatic resize with dialog doesn't work?

Post by Lord »

Marc56us wrote:
Lord wrote:Nobody agrees or disagrees with my observation?
I think that despite its qualities, there are very few people who use the dialog library.
One of the main reasons being the tedious side of the XML language.
(12 years of PB and I've never used it: I do everything by myself with internal Form Designer (Even for small resizable interfaces )

That said, wait a few days. No need to do a UP after 2 days.

:wink:
I just wonder why no one has noticed/reported the error(?) yet,
even if only a few are working with it
RASHAD wrote:Hi Lord
I did my best to find any solution but doing it manually as you can do it
But no success
The only afford tech. by PureBasic is RefreshDialog(#Dialog) which will bring you back to the original XML
FYI I did it only manually I mean out of XML by ResizeGadget() but still using code :)
Yes, it is easily possible to work around this by using a manual release and
resize via BindEvent(). But that's not the intention of the dialog library, is it?
Image
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Automatic resize with dialog doesn't work?

Post by Rinzwind »

Hiding ('invisible') also doesn't do anything.
The main purpose of this stuff should be 'dynamic' (that's what I hoped), which it clearly isn't.

*Node = XMLNodeFromID(xmlGUI, "#Progressbar" )
If *Node
DeleteXMLNode(*Node)

also won't change anything. One can't add gadgets too. Alas..
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Automatic resize with dialog doesn't work?

Post by Lunasole »

I've encountered the same while dealing with dialogs too. Didn't considered this is a bug.
As for me there is some different concept between dialogs and regular windows, dialogs are not meant to be dynamically redefined and rely on a bit different OS mechanism.

So they have some limitations, maybe it can be bypassed at more low level, but I didn't found effective solution from those my old attempts. Anyway I'm using dialogs like described here, never destroying items which were predefined in XML (but can add some items dynamically).
As I remember also, It can further lead to IMA errors after performing things like this (freeing some predefined controls after dialog created and used).
So I'd say nothing to do with that, just use dialogs where it is enough. Or build custom windows if need some more abilities.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Post Reply