Dialog and small button

Just starting out? Need help? Post your questions and find answers here.
Mesa
Enthusiast
Enthusiast
Posts: 447
Joined: Fri Feb 24, 2012 10:19 am

Dialog and small button

Post by Mesa »

Is there a way to create small imagebuttons with the dialog library, it seems there is a minimum size for it ?
I want an imagebutton sizing 9x9.
i've tried with gridbox, other boxes + empty, but nothing works.

[Edit: oops]

Code: Select all

;
;/-------------------------
;|
;| Names, IDs, Procedures
;|
;| Example Template for Dialog Design0R
;|
;/-------------------------


#DD_WindowCount = 1
#DD_UseExtraStuff = 0

CompilerIf #DD_UseExtraStuff
	XIncludeFile ""
CompilerEndIf

Runtime Enumeration Windows
	#window
EndEnumeration


Global Dim DD_WindowNames.s(#DD_WindowCount)

DD_WindowNames(1) = "window"


Runtime Enumeration Gadgets
	#text_1
	#buttonimage_1
	#tree_1
EndEnumeration


Procedure.s GetXMLString()
	Protected XML$

	XML$ + "<?xml version='1.0' encoding='UTF-16'?>"
	XML$ + ""
	XML$ + "<dialogs><!--Created by Dialog Design0R V1.85 => get it from: https://hex0rs.coderbu.de/en/sdm_downloads/dialogdesign0r/-->"
	XML$ + "  <window flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered' width='800' height='600' margin='vertical:0,horizontal:0' name='window' xpos='104' ypos='104' id='#window'>"
	XML$ + "    <vbox expand='item:2' spacing='0'>"
	XML$ + "      <hbox expand='item:2' height='10'>"
	XML$ + "        <singlebox>"
	XML$ + "          <text text='Text' id='#text_1'/>"
	XML$ + "        </singlebox>"
	XML$ + "        <empty/>"
	XML$ + "        <buttonimage width='9' height='9' id='#buttonimage_1'/>"
	XML$ + "      </hbox>"
	XML$ + "      <tree id='#tree_1'/>"
	XML$ + "    </vbox>"
	XML$ + "  </window>"
	XML$ + "</dialogs><!--DDesign0R Definition: PureBasic|1|1|1|_|-|1-->"
	XML$ + ""

	ProcedureReturn XML$
EndProcedure
;Test it
CompilerIf #PB_Compiler_IsMainFile
	
	CompilerIf Defined(GetXMLString, #PB_Procedure)
		a$ = GetXMLString()
		ParseXML(0, a$)
	CompilerElse
		LoadXML(0, Left(#PB_Compiler_File, Len(#PB_Compiler_File) - 7))
	CompilerEndIf

	If XMLStatus(0) = #PB_XML_Success
		For i = 1 To #DD_WindowCount
			CreateDialog(i)
			CompilerIf #DD_UseExtraStuff
				R = DEX::InitDialog(i, 0, DD_WindowNames(i), 1)
			CompilerElse
				R = OpenXMLDialog(i, 0, DD_WindowNames(i))
			CompilerEndif
			If R
				HideWindow(DialogWindow(i), 0)
				ok = #True
			Else
				Debug DialogError(i)
			EndIf
		Next i
		CompilerIf Defined(PB_OS_Web, #PB_Constant) = 0 Or #PB_Compiler_OS <> #PB_OS_Web
			If ok
				While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
			EndIf
		CompilerEndIf
	Else
		Debug XMLStatus(0)
		Debug XMLError(0)
	EndIf
	CompilerIf #DD_UseExtraStuff
		DEX::DeInit()
	CompilerEndif

CompilerEndif

;(c) HeX0R 2021

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>

<dialogs><!--Created by Dialog Design0R V1.85 => get it from: https://hex0rs.coderbu.de/en/sdm_downloads/dialogdesign0r/-->
  <window flags="#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered" width="800" height="600" margin="vertical:0,horizontal:0" name="window" xpos="104" ypos="104" id="#window">
    <vbox expand="item:2" spacing="0">
      <hbox expand="item:2" height="10">
        <singlebox>
          <text text="Text" id="#text_1"/>
        </singlebox>
        <empty/>
        <buttonimage width="9" height="9" id="#buttonimage_1"/>
      </hbox>
      <tree id="#tree_1"/>
    </vbox>
  </window>
</dialogs><!--DDesign0R Definition: PureBasic|1|1|1|_|-|1-->
M.
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Dialog and small button

Post by Caronte3D »

For such a small size, maybe it's better to use an image instead of a button? :?
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Dialog and small button

Post by boddhi »

Hi,
Mesa wrote:Is there a way to create small imagebuttons with the dialog library, it seems there is a minimum size for it ?
Try this:

Code: Select all

    	XML$ + "<?xml version='1.0' encoding='UTF-16'?>"
    	XML$ + ""
    	XML$ + "<dialogs><!--Created by Dialog Design0R V1.85 => get it from: https://hex0rs.coderbu.de/en/sdm_downloads/dialogdesign0r/-->"
    	XML$ + "  <window flags='#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered' width='800' height='600' margin='vertical:0,horizontal:0' name='window' xpos='104' ypos='104' id='#window'>"
    	XML$ + "    <vbox expand='item:2' spacing='0'>"
    	XML$ + "      <hbox expand='item:2' height='10'>"
    	XML$ + "        <singlebox>"
    	XML$ + "          <text text='Text' id='#text_1'/>"
    	XML$ + "        </singlebox>"
    	XML$ + "        <empty/>"
;
XML$ + "        <vbox expand='no' align='center'>" ; =>   vbox expand='no' is the most important, align='center' is optional, just for pretty look.
XML$ + "          <buttonimage width='9' height='9' id='#buttonimage_1'/>"
XML$ + "        </vbox>"
;
    	XML$ + "      </hbox>"
    	XML$ + "      <tree id='#tree_1'/>"
    	XML$ + "    </vbox>"
    	XML$ + "  </window>"
    	XML$ + "</dialogs><!--DDesign0R Definition: PureBasic|1|1|1|_|-|1-->"
    	XML$ + ""
Result (with DPI 125%):
Image
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply