Seite 1 von 1
PB 5.2 Dialog
Verfasst: 02.07.2013 16:13
von Andreas21
Code: Alles auswählen
Define Dialog, Xml, Button
;<option text="option 1" .... onevent="CheckBoxEvent()"/>
Runtime Procedure CheckBoxEvent()
Debug "Option 1 clicked!"
EndProcedure
Xml = LoadXML(#PB_Any, "ui.xml")
If IsXML(Xml)
If XMLStatus(Xml) = #PB_XML_Success
Dialog = CreateDialog(#PB_Any)
;<window .... name="hello"
If OpenXMLDialog(Dialog, Xml, "hello")
;<window id="0"
HideWindow(0, #False)
;<button text="Ole 2" name="button"/>
Button = DialogGadget(Dialog,"button")
If IsGadget(Button)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case Button
Debug "Button Ole 2 clicked!"
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Else
Debug "Dialog creation error: " + DialogError(Dialog)
EndIf
Else
Debug "XML error on line " + XMLErrorLine(Xml) + ": " + XMLError(Xml)
EndIf
EndIf
ui.xml
Code: Alles auswählen
<?xml version="1.0"?>
<!-- Window -->
<window id="0" name="hello" text="Window" label="TestDialog" width="320" height="10" flags="#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget">
<splitter width="300" height="500">
<hbox>
<checkbox name="checkbox1" text="Run only one Instance" disabled="yes" Flags=""/>
<progressbar text="Vrey vreyv rye"/>
<trackbar text="Ole" invisible="no" Flags="#PB_TrackBar_Ticks" width="150"/>
<option text="option 1" name="option1" onevent="CheckBoxEvent()"/>
<option text="option 2"/>
</hbox>
<vbox>
<listview text="option 3" height="50"/>
<button text="Ole 2" name="button"/>
<listicon text="option 4" height="50"/>
<string text="string content"/>
<editor text="editorgadget" height="50"/>
<text text="Text gadget"/>
</vbox>
</splitter>
</window>
Vorlage von Fred
http://www.purebasic.fr/english/viewtop ... 14&t=54999
Re: PB 5.2 Dialog
Verfasst: 02.07.2013 16:40
von Kiffi
hier mit BindGadgetEvent():
Code: Alles auswählen
Define Dialog, Xml, Button
;<option text="option 1" .... onevent="CheckBoxEvent()"/>
Runtime Procedure CheckBoxEvent()
Debug "Option 1 clicked!"
EndProcedure
;<button text="Ole 2" name="button"/>
Procedure Button_LeftClick()
Debug "Button Ole 2 clicked!"
EndProcedure
Xml = LoadXML(#PB_Any, "ui.xml")
If IsXML(Xml)
If XMLStatus(Xml) = #PB_XML_Success
Dialog = CreateDialog(#PB_Any)
;<window .... name="hello"
If OpenXMLDialog(Dialog, Xml, "hello")
;<window id="0"
HideWindow(0, #False)
;<button text="Ole 2" name="button"/>
Button = DialogGadget(Dialog,"button")
BindGadgetEvent(Button, @Button_LeftClick(), #PB_EventType_LeftClick)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Else
Debug "Dialog creation error: " + DialogError(Dialog)
EndIf
Else
Debug "XML error on line " + XMLErrorLine(Xml) + ": " + XMLError(Xml)
EndIf
EndIf
Grüße ... Kiffi
Re: PB 5.2 Dialog
Verfasst: 04.07.2013 12:08
von Andreas21
Wie man bei der Fenster ID, #PB_Any nutzen kann habe ich noch nicht raus gefunden.
Feste IDs wie z.b. 0 mag ich normal nicht.
Ist unflexibel.
Könnte interessant sein wenn der Form Designer auch in xml speichern könnte.
So könnte man Forms auch nachträglich bearbeiten.
Re: PB 5.2 Dialog
Verfasst: 04.07.2013 13:01
von Kiffi
Andreas21 hat geschrieben:Wie man bei der Fenster ID, #PB_Any nutzen kann habe ich noch nicht raus gefunden.
Wenn Du id weglässt, wird #PB_Any verwendet:
Fred hat geschrieben:- "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().
Andreas21 hat geschrieben:Könnte interessant sein wenn der Form Designer auch in xml speichern könnte.
So könnte man Forms auch nachträglich bearbeiten.
so ist zumindest der Plan. Wenn Polo mal in die Puschen kommen würde...
Grüße ... Kiffi
Re: PB 5.2 Dialog
Verfasst: 04.07.2013 14:28
von Andreas21
Code: Alles auswählen
Define Dialog, Xml, Button, Window
;<option text="option 1" .... onevent="CheckBoxEvent()"/>
Runtime Procedure CheckBoxEvent()
Debug "Option 1 clicked!"
EndProcedure
Xml = LoadXML(#PB_Any, "ui.xml")
If IsXML(Xml)
If XMLStatus(Xml) = #PB_XML_Success
Dialog = CreateDialog(#PB_Any)
;<window .... name="hello"
OpenXMLDialog(Dialog, Xml, "hello")
Window = DialogWindow(Dialog)
If IsWindow(Window)
;<window id="0"
HideWindow(Window, #False)
;<button text="Ole 2" name="button"/>
Button = DialogGadget(Dialog,"button")
If IsGadget(Button)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case Button
Debug "Button Ole 2 clicked!"
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Else
Debug "Dialog creation error: " + DialogError(Dialog)
EndIf
Else
Debug "XML error on line " + XMLErrorLine(Xml) + ": " + XMLError(Xml)
EndIf
EndIf