multiline string gadget with dialog library

Just starting out? Need help? Post your questions and find answers here.
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

multiline string gadget with dialog library

Post by nsstudios »

Hi,

I tried to convert my gadget code to dialog library, and I have a problem.
I use the following flags for my string gadgets:

Code: Select all

#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL| #WS_VSCROLL
Using them in the dialog xml results in an error, even if if I make them available through runtime.
Is there any way to still make string gadgets with dialog library with those flags?
I would use editor gadget, but it hooks the tab key, and all of the examples I've seen for disabling that behavior are for Windows only, and I'd still need the extra Windows flags anyway.

I'd really appreciate a solution to this problem.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: multiline string gadget with dialog library

Post by RASHAD »

There is noway to change the properties of the StringGadget() after creation
Next is a workaround
Remember to use id='?'

Code: Select all

EnableExplicit

Global dlg_window1 = CreateDialog(#PB_Any)
Global DialogsXML$ = #Empty$
DialogsXML$ +
   "<dialogs>" +
   "   <window name='window1' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget| #PB_Window_ScreenCentered'>" +
   "      <string name='editor1' id='0' width='200' height='100'/>" +
   "   </window>" +
   "</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)
Define x,y,w,h

If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
  Define editor = DialogGadget(dlg_window1, "editor1")
  x = GadgetX(editor)
  y = GadgetY(editor)
  w = GadgetWidth(editor)
  h = GadgetHeight(editor)
   FreeGadget(editor)
   StringGadget(editor,x,y,w,h,"",#ES_MULTILINE|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT|#ES_AUTOVSCROLL|#ES_AUTOHSCROLL| #WS_VSCROLL)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_VERT,0)
  ;SendMessage_(GadgetID(editor),#EM_SHOWSCROLLBAR, #SB_HORZ,0)

  SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: multiline string gadget with dialog library

Post by nsstudios »

Good idea! Thanks.
Post Reply