runtime constants for dialog library flags

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

runtime constants for dialog library flags

Post by nsstudios »

Hi,

I've been trying to use dialog library, because it really makes my life easier, but I have a problem.
I need to use OS-specific flags for certain gadgets, e.g., string gadget, which dialog library does not support, and it would be really really nice if it let me specify runtime constants for them and then use it with the dialog.
I've tried loading a dialog and then manually freeing/recreating gadgets that I need the extra flags for, but that changes the tab order (the newly recreated gadgets appear last in the tab order).

Example (uncomment CompilerIf to see difference between recreated gadgets and not):

Code: Select all

EnableExplicit
Runtime Enumeration gadgets: #l1: #msg: #l2: #l: #l3: #d: #l4: #filt: EndEnumeration
#flags=#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL|#WS_VSCROLL
LoadXML(0, "z.xml")
Define err.s=XMLError(0)
If err>""
MessageRequester(err, ""+XMLErrorLine(0)+", "+XMLErrorPosition(0))
EndIf
CreateDialog(0)
OpenXMLDialog(0, 0, "test")
err=DialogError(0)
If err>""
MessageRequester("error", err)
EndIf
;CompilerIf 0
Define g=DialogGadget(0, "msg")
If g=-1: debug "Can't find gadget.": CallDebugger: EndIf
Define gx=GadgetX(g), gy=GadgetY(g), gw=GadgetWidth(g), gh=GadgetHeight(g)
FreeGadget(g)
StringGadget(g, gx, gy, gw, gh, "", #flags)
g=DialogGadget(0, "d")
If g=-1: debug "Can't find gadget.": CallDebugger: EndIf
Define gx=GadgetX(g), gy=GadgetY(g), gw=GadgetWidth(g), gh=GadgetHeight(g)
FreeGadget(g)
StringGadget(g, gx, gy, gw, gh, "", #flags)
;CompilerEndIf

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow

Code: Select all

<window id="0" name="test" text="test" flags="#pb_window_screenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget" minwidth="auto" minheight="auto" maxwidth="auto" maxheight="auto">
<hBox>
<vBox>
<text id="#l1" name="l1" text="message"/>
<string id="#msg" name="msg"/>
</vBox>
<vBox>
<text id="#l2" name="l2" text="chats"/>
<listicon id="#l" name="l"/>
</vBox>
<vBox>
<text id="#l3" name="l3" text="viewer"/>
<string id="#d" name="d"/>
</vBox>
<vBox>
<text id="#l4" name="l4" text="filter"/>
<listview id="#filt" name="filt"/>
</vBox>
</hBox>
</window>