Page 1 of 1

Is there a trick to remove margins in Dialogs ?

Posted: Wed Jul 15, 2020 1:52 pm
by Mesa
See the differences between dialog (top) and no dialog (bottom).
Is there a solution ?

Code: Select all

#Dialog = 0
#Xml = 0

XML$ = ~"<dialogs>\n"
XML$ + ~"  <window name='test' flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget'>\n"
XML$ + ~"    <vbox spacing='0' expand='no'>\n"
XML$ + ~"      <panel name='panel_1' height='100' margin='vertical:-5,horizontal:-5'>\n"
XML$ + ~"        <tab text='Dialog=margins (panel and canvas)'>\n"
XML$ + ~"          <canvas name='canvas_1' margin='left:-5,right:-5,bottom:-5,vertical:-5,horizontal:-5'/>\n"
XML$ + ~"        </tab>\n"
XML$ + ~"      </panel>\n"
XML$ + ~"    </vbox>\n"
XML$ + ~"  </window>\n"
XML$ + ~"</dialogs>\n"
XML$ + ~""

If ParseXML(#Xml, XML$) And XMLStatus(#Xml) = #PB_XML_Success
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    hwd=DialogWindow(#Dialog) 
    PanelGadget(0,0,150,600,100)
    AddGadgetItem (0, -1, "No Dialog=No margins (panel and canvas)")
    CanvasGadget(1,0,0,600,100)
    CloseGadgetList()
    ResizeWindow(hwd,#PB_Ignore,#PB_Ignore,600,400)
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow 
    
  Else  
    Debug "Error : " + DialogError(#Dialog)
  EndIf
Else
  Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
M.

Re: Is there a trick to remove margins in Dialogs ?

Posted: Wed Jul 15, 2020 2:16 pm
by Cyllceaux
easy

Code: Select all

<window margin='0'
It's not documented, but the window has a margin attribute, too.

Re: Is there a trick to remove margins in Dialogs ?

Posted: Wed Jul 15, 2020 5:42 pm
by Mesa
Thanks.

The solution is:

Code: Select all

#Dialog = 0 
#Xml = 0 
	 
XML$ = ~"<dialogs>\n"
XML$ + ~"  <window flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget' name='test'>\n"
XML$ + ~"    <singlebox expand='horizontal' margin='vertical:-8,horizontal:-9'>\n"
XML$ + ~"      <panel name='panel_1'>\n"
XML$ + ~"        <tab>\n"
XML$ + ~"          <singlebox expand='horizontal' margin='vertical:-9,horizontal:-10'>\n"
XML$ + ~"            <canvas width='300' height='100' name='canvas_1'/> \n"
XML$ + ~"          </singlebox>\n"
XML$ + ~"        </tab>\n"
XML$ + ~"        <tab/> \n"
XML$ + ~"      </panel>\n"
XML$ + ~"    </singlebox> \n"
XML$ + ~"  </window>\n"
XML$ + ~"</dialogs>\n"
XML$ + ~"" 
	 
	If ParseXML(#Xml, XML$) And XMLStatus(#Xml) = #PB_XML_Success 
		 
		If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test") 
			hwd=DialogWindow(#Dialog)  
			PanelGadget(0,0,150,600,100) 
			AddGadgetItem (0, -1, "No Dialog=No margins (panel and canvas)") 
			CanvasGadget(1,0,0,600,100) 
			CloseGadgetList() 
			ResizeWindow(hwd,#PB_Ignore,#PB_Ignore,600,400) 
			Repeat 
				Event = WaitWindowEvent() 
			Until Event = #PB_Event_CloseWindow  
			 
		Else   
			Debug "Error : " + DialogError(#Dialog) 
		EndIf 
	Else 
		Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")" 
	EndIf 
M.

Re: Is there a trick to remove margins in Dialogs ?

Posted: Wed Jul 15, 2020 6:24 pm
by RASHAD
Hi
No need for any extra object

Code: Select all

XML$ = ~"<dialogs>\n"
XML$ + ~"  <window name='test' margin='left:0,top:10,right:10,bottom:10' flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget'>\n"
XML$ + ~"    <vbox spacing='0' expand='no'>\n"
XML$ + ~"      <panel name='panel_1' height='100' margin='vertical:-5,horizontal:-5'>\n"
XML$ + ~"        <tab text='Dialog=margins (panel and canvas)'>\n"
XML$ + ~"          <canvas name='canvas_1' margin='left:-5,right:-5,bottom:-5,vertical:-5,horizontal:-5'/>\n"
XML$ + ~"        </tab>\n"
XML$ + ~"      </panel>\n"
XML$ + ~"    </vbox>\n"
XML$ + ~"  </window>\n"
XML$ + ~"</dialogs>\n"
XML$ + ~""

Re: Is there a trick to remove margins in Dialogs ?

Posted: Thu Jul 16, 2020 9:54 am
by dige
Cool, We can do a lot more with the Dialog Library, als only creating gadgets. Is there a website where these styles are described?

You can also use a dialog within an existing (Container)gadget?

Ciao Dige