Page 5 of 5

Re: MODULE: DynamicDialogs - creating complex GUIs the easy

Posted: Mon Nov 20, 2023 10:49 pm
by Quin
PureLust wrote: Mon Jan 17, 2022 8:11 pm
nsstudios wrote: Fri Oct 23, 2020 6:44 pmIt seems like supplying the multiline flag to a string gadget does nothing... for some reason.
Yes, you are right.
Because DynDialogs uses the PB internal Dialog functions, and they don't support any other Flags than original PB-Parameters, API-Parameter do not work here ... sorry.
And BP does not support changing Flags after the Gadget was generated, so you cannot add multiline afterwards using genuine PB functions.
But ... maybe you could use API functions to add multiline support afterwards - I bet you will find some information about this here in the forum.
Has anyone successfully done this? I've tried this:

Code: Select all

SetWindowLongPtr_(GadgetID(#MessageField), #GWL_STYLE, GetWindowLongPtr_(GadgetID(#MessageField), #GWL_STYLE) | #ES_MULTILINE | #ES_AUTOVSCROLL)
It doesn't actually make the gadget multiline though. It tricks my screen reader into saying "multiline", but doesn't actually do it.

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Mon Nov 20, 2023 10:57 pm
by jacdelad
You can fool the inbuilt by using a fixed constant as identifier and creating a new StringGadget over your current one (and use the constants on creation). This should work with this module too.

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Tue Nov 21, 2023 5:36 pm
by Quin
jacdelad wrote: Mon Nov 20, 2023 10:57 pm You can fool the inbuilt by using a fixed constant as identifier and creating a new StringGadget over your current one (and use the constants on creation). This should work with this module too.
I originally did that when using the standard dialog library, but I'm not certain if that'll mess up the autosizing. Is just getting the GadgetX, Y, Width, and Height good enough to draw it?

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Wed Nov 22, 2023 2:03 am
by ChrisR
Quin wrote: Tue Nov 21, 2023 5:36 pm Is just getting the GadgetX, Y, Width, and Height good enough to draw it?
Try this

Code: Select all

EnableExplicit

Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
  #String_1
  #String_2
EndEnumeration

Enumeration Font
  #Font
EndEnumeration

LoadFont(#Font, "Tahoma", 8, #PB_Font_Italic)

Macro _IsFlag_(StyleFlag, IsFlag)
  Bool((StyleFlag & IsFlag) = IsFlag)
EndMacro

Procedure NewStringGadget(Gadget, AddFlag)
  If Gadget > 9999 Or Not(IsGadget(Gadget)) Or Not(GadgetType(Gadget) = #PB_GadgetType_String) : ProcedureReturn : EndIf     ; Only with a fixed constant < 10000
  Protected ReturnVal
  Protected StyleFlag     = GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE)
  Protected ExStyleFlag   = GetWindowLongPtr_(GadgetID(Gadget), #GWL_EXSTYLE)
  Protected IDFont        = GetGadgetFont(Gadget)
  Protected BackColor     = GetGadgetColor(Gadget, #PB_Gadget_BackColor)
  Protected FrontColor    = GetGadgetColor(Gadget, #PB_Gadget_FrontColor)
  Protected MaximumLength = GetGadgetAttribute(Gadget, #PB_String_MaximumLength)
  Protected IsDisable     = IsWindowEnabled_(GadgetID(Gadget)) ! 1
  Protected IsHiden       = IsWindowVisible_(GadgetID(Gadget)) ! 1
  
  If _IsFlag_(StyleFlag, #ES_NUMBER)               : AddFlag | #PB_String_Numeric    : EndIf
  If _IsFlag_(StyleFlag, #ES_PASSWORD)             : AddFlag | #PB_String_Password   : EndIf
  If _IsFlag_(StyleFlag, #ES_READONLY)             : AddFlag | #PB_String_ReadOnly   : EndIf
  If _IsFlag_(StyleFlag, #ES_LOWERCASE)            : AddFlag | #PB_String_LowerCase  : EndIf
  If _IsFlag_(StyleFlag, #ES_UPPERCASE)            : AddFlag | #PB_String_UpperCase  : EndIf
  If Not(_IsFlag_(ExStyleFlag, #WS_EX_CLIENTEDGE)) : AddFlag | #PB_String_BorderLess : EndIf
  ; Others Edit Control Styles: https://learn.microsoft.com/en-us/windows/win32/controls/edit-control-styles
  If _IsFlag_(StyleFlag, #ES_CENTER)               : AddFlag | #ES_CENTER            : EndIf
  If _IsFlag_(StyleFlag, #ES_MULTILINE)            : AddFlag | #ES_MULTILINE         : EndIf
  If _IsFlag_(StyleFlag, #ES_NOHIDESEL)            : AddFlag | #ES_NOHIDESEL         : EndIf
  If _IsFlag_(StyleFlag, #ES_RIGHT)                : AddFlag | #ES_RIGHT             : EndIf
  
  ReturnVal = StringGadget(Gadget, GadgetX(Gadget), GadgetY(Gadget), GadgetWidth(Gadget), GadgetHeight(Gadget), GetGadgetText(Gadget), AddFlag)
  
  SetGadgetFont(Gadget, IDFont)
  SetGadgetColor(Gadget, #PB_Gadget_BackColor, BackColor)
  SetGadgetColor(Gadget, #PB_Gadget_FrontColor, FrontColor)
  
  SetGadgetAttribute(Gadget, #PB_String_MaximumLength, MaximumLength)
  
  DisableGadget(Gadget, IsDisable)
  HideGadget(Gadget, IsHiden)
  
  ProcedureReturn ReturnVal
EndProcedure

Procedure Open_Window_0(X = 0, Y = 0, Width = 220, Height = 130)
  Protected LongText.s = "This is a MultiLine String Gadget. I would say even more, this is a MultiLine String Gadget"
  If OpenWindow(#Window_0, X, Y, Width, Height, "Recreate StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    StringGadget(#String_1, 20, 10, 180, 50, LongText, #ES_CENTER | #ES_MULTILINE)
    StringGadget(#String_2, 20, 70, 180, 50, LongText)
    SetGadgetColor(#String_2, #PB_Gadget_BackColor, #Cyan) : SetGadgetColor(#String_2, #PB_Gadget_FrontColor, #Red)
    SetGadgetFont(#String_2, FontID(#Font))
    ;DisableGadget(#String_2, #True)
  EndIf
EndProcedure

Open_Window_0()

;SetWindowLongPtr_(GadgetID(#String_2), #GWL_STYLE, GetWindowLongPtr_(GadgetID(#String_2), #GWL_STYLE)  #ES_CENTER | #ES_MULTILINE)   ; DOES NOT WORK
NewStringGadget(#String_2, #ES_CENTER | #ES_MULTILINE)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Wed Nov 22, 2023 1:47 pm
by Quin
I assume the answer to this is a no, but can I do this without destroying and recreating the gadget? This screws with the tab order of things. Also, I put TextGadgets above my String ones for labels and they don't work if I use any of these methods.

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Wed Nov 22, 2023 2:02 pm
by jacdelad
Can you post a simple example to show your exact problem?

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Sat Mar 23, 2024 2:04 am
by Quin
Life got really busy and I ended up not needing to do this as soon as I thought. Now I'm trying it again, and I still can't get it to work. Here's my test program:

Code: Select all

EnableExplicit

XIncludeFile "../DynamicDialogs/DynamicDialogs_Suffixed.pbi"

UseModule DynamicDialogs
UseModule DynamicDialogs_suffixed
ClearXML()
SetXMLOutputFormat(#XMLout_Indent, 2)
SetXMLOutputFormat(#XMLout_AlignLineBreak, #True)
Window__(0, "", "Test")
	VBox__()
		Text__(#PB_Any, "", "Message")
		String__(0, "", "This is a test")
	EndVBox__()
EndWindow__()
UnuseModule DynamicDialogs_suffixed
Define XMLWinMain$ = GetXML()
OpenDialogWindow(0, XMLWinMain$, 0)
UnuseModule DynamicDialogs
Define OrigStyle = GetWindowLongPtr_(WindowID(0), #GWL_STYLE)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, OrigStyle | #ES_MULTILINE | #ES_AUTOVSCROLL)
SetActiveGadget(0)

Repeat
	Define Event = WaitWindowEvent(1)
Until Event = #PB_Event_CloseWindow
Notice that I put a label above the text field. This makes it so my screen reader tells me what the field is for. If I use the method of removing the gadget and re-adding it, the label no longer gets read for some reason.
Any tips?

Re: MODULE: DynamicDialogs - creating complex GUIs the easy way

Posted: Fri Feb 07, 2025 6:42 am
by Quin
Hello,
In PB 6.20, if you want to be able to use the newly introduced #PB_Editor_TabNavigation flag with EditorGadgets created with DynamicDialogs, put this on line 1857 of DynamicDialogs_MainModul.pbi:

Code: Select all

If flags & #PB_Editor_TabNavigation = #PB_Editor_TabNavigation : XML$ + "#PB_Editor_TabNavigation | " : EndIf
:)