Questions about the new XmlDialog

Everything else that doesn't fall into one of the other PB categories.
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Questions about the new XmlDialog

Post by Kiffi »

Code: Select all

<window id="0" name="hello" text="Window" label="TestDialog" width="640" height="480" flags="#PB_Window_SizeGadget">
  • What's the difference between id and name?
  • What is label for?
  • How to position a dialog? Neither y/x nor top/left work for me
Thanks in advance and greetings ... Kiffi
Hygge
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post by Fred »

- "id" is the purebasic #Window id of the created dialog (if missing, it will be #PB_Any). "name" is the name you need to put in OpenXMLDialog().
- "label" is an error, it's not supported and does nothing.
- about x,y: true, it should be added to OpenXMLDialog().

You can use ResizeWindow() for now if you need it.
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post by Kiffi »

Thanks for your fast reply!

Greetings ... Kiffi
Hygge
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Questions about the new XmlDialog

Post by BorisTheOld »

@Fred

If I create an XML gui file using Glade, will PB be able to understand it?

Thanks
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post by Fred »

No, it's custom PB XML.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Questions about the new XmlDialog

Post by BorisTheOld »

Thanks
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Questions about the new XmlDialog

Post by Little John »

Fred wrote:- "label" is an error, it's not supported and does nothing.
In the current version 5.20 beta 11, the example file "ui.xml" still contains the text
label="TestDialog"
This is confusing, please remove the text.
Fred wrote:- about x,y: true, it should be added to OpenXMLDialog().
Documemtation of PB 5.20 beta 11 wrote:Result = OpenXMLDialog(#Dialog, #XML, Name$)
Did you make a different decision in the meantime, or does OpenXMLDialog() now haven x and y parameters, and this is just not documented?
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post by Kiffi »

Little John wrote:does OpenXMLDialog() now haven x and y parameters
since 5.20 B12 it works. Thanks!
Result = OpenXMLDialog(#Dialog, #XML, Name$ [, x, y [, Width, Height [, ParentID]]])
Also #PB_Window_ScreenCentered is now supported. :D But unfortunately
the top / left position of the window is now centered. Not the window itself. ;-)

Code: Select all

#Dialog = 0
#Xml = 0

Define XML.s

XML = "<window id=''#PB_Any'' width=''500'' height=''500'' name=''test'' text=''test'' flags=''#PB_Window_ScreenCentered | #PB_Window_SystemMenu''>"
XML + "</window>"

XML = ReplaceString(XML, "''", Chr(34))
CatchXML(#Xml, @XML, Len(XML))
Result = CreateDialog(#Dialog)
Result = OpenXMLDialog(#Dialog, #Xml, "test")
HideWindow(DialogWindow(#Dialog), #False)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Greetings ... Kiffi
Hygge
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post by Fred »

You also don't need to use HideWindow() anymore (unless #PB_Window_Invisible is set, indeed).
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Questions about the new XmlDialog

Post by Little John »

Thanks.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Questions about the new XmlDialog

Post by IdeasVacuum »

Kiffi's code will not compile on WinXP x86 PB5.20 Beta12:

Code: Select all

#Dialog = 0
#Xml = 0

Define XML.s

XML = "<window id=''#PB_Any'' width=''500'' height=''500'' name=''test'' text=''test'' flags=''#PB_Window_ScreenCentered | #PB_Window_SystemMenu''>"
XML + "</window>"

XML = ReplaceString(XML, "''", Chr(34))
CatchXML(#Xml, @XML, Len(XML))
Result = CreateDialog(#Dialog)
Result = OpenXMLDialog(#Dialog, #Xml, "test")
HideWindow(DialogWindow(#Dialog), #False)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Takes a month of Sundays, then fails: (1) HideWindow(); (2) WaitWindowEvent().
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Questions about the new XmlDialog

Post by ts-soft »

@IdeasVacuum
Use ASCII-Compilermode.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Questions about the new XmlDialog

Post by Little John »

ts-soft wrote:@IdeasVacuum
Use ASCII-Compilermode.
... or replace

Code: Select all

CatchXML(#Xml, @XML, Len(XML))
with

Code: Select all

CatchXML(#Xml, @XML, StringByteLength(XML))
:)
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Re: Questions about the new XmlDialog

Post by akj »

Why does this slight variation of Kiffi's code generate a date gadget of enormous size? How do I specify a size of 200 x 50 pixels?

Code: Select all

#Dialog = 0
#Xml = 0

Define XML.s
XML = "<window id=''#PB_Any'' width=''500'' height=''500'' name=''test'' text=''test'' flags=''#PB_Window_ScreenCentered | #PB_Window_SystemMenu''>"
XML + "<date name=''datenow'' width=''200'' height=''50'' />" ; Extra code
XML + "</window>"

XML = ReplaceString(XML, "''", Chr(34))
CatchXML(#Xml, @XML, Len(XML))
Result = CreateDialog(#Dialog)
Result = OpenXMLDialog(#Dialog, #Xml, "test")
;!!! HideWindow(DialogWindow(#Dialog), #False)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Anthony Jordan
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post by Kiffi »

akj wrote:How do I specify a size of 200 x 50 pixels?
you must use hbox and vbox:

Code: Select all

XML + "<vbox expand=''no''>" ; Extra code
XML + " <hbox expand=''no''>" ; Extra code
XML + "  <date name=''datenow'' width=''200'' height=''50'' />" ; Extra code
XML + " </hbox>" ; Extra code
XML + "</vbox>" ; Extra code
Greetings ... Kiffi
Hygge
Post Reply