Because it's still not supported native I've made a very little Proc, to easily align any kind of Dialog-Element:
Code: Select all
Procedure.s Align_Element(XML_Code.s, Align.s="center", Margin.l=0)
ProcedureReturn "<singlebox align='"+Align+"' margin='0' expand='horizontal'><singlebox align='"+Align+"' margin='"+Str(Margin)+"' expand='vertical'>" + XML_Code+"</singlebox></singlebox>"
EndProcedure


Example Code:
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_Unicode
#XmlEncoding = #PB_UTF8
CompilerElse
#XmlEncoding = #PB_Ascii
CompilerEndIf
#Dialog = 0
#Xml = 0
Procedure.s Align_Element(XML_Code.s, Align.s="center", Margin.l=0)
ProcedureReturn "<singlebox align='"+Align+"' margin='0' expand='horizontal'><singlebox align='"+Align+"' margin='"+Str(Margin)+"' expand='vertical'>" + XML_Code+"</singlebox></singlebox>"
EndProcedure
Define Button$ = "<button width='30' height='10'/>" ; just put some often used frases into variables to shorten the code
Define ButtonRow$ = "<button colspan='7'/>" ; just put some often used frases into variables to shorten the code
Define XML$ = "<window id='#PB_Any' name='test' text='Align_Element() Test' minwidth='400' minheight='200' width='600' height='400' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
"<gridbox columns='7' colexpand='yes' rowexpand='yes' colspacing='0' rowspacing='0'>" +
ButtonRow$ + Button$ +
Align_Element("<text text='top, left'/>" , "top, left" ) + Button$ +
Align_Element("<text text='top, center'/>" , "top, center") + Button$ +
Align_Element("<text text='top, right'/>" , "top, right" ) + Button$ +
ButtonRow$ + Button$ +
Align_Element("<button text='left, center'/>" , "left, center" ) + Button$ +
Align_Element("<button text='center'/>" , "center" ) + Button$ +
Align_Element("<button text='right, center'/>" , "right, center") + Button$ +
ButtonRow$ + Button$ +
Align_Element("<checkbox text='bottom, left'/>" , "bottom, left" ,5) + Button$ + ; the last 3 Gadgets are with a margin of 5 pixels
Align_Element("<checkbox text='bottom, center'/>" , "bottom, center" ,5) + Button$ +
Align_Element("<checkbox text='bottom, right'/>" , "bottom, right" ,5) + Button$ +
ButtonRow$ +
"</gridbox>" +
"</window>"
If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
Repeat
Define Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf