Editor/RTF control styling (Windows)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Editor/RTF control styling (Windows)

Post by Lunasole »

Hi.
I need vertical scrollbar on Editor to be fixed (instead of automatically appear/disappear depend on text size).
For that ES_DISABLENOSCROLL style can be applied, but looks like that doesn't work for existing control (need to set it when creating).

To be exact I'm just trying to make text with WordWrap flag look fine, and that "dynamical" scrollbar turns it bad.
Any ideas how that can be done (except creating control directly through WinAPI or using external scrollbar)^^?

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'>" +
	"		<editor name='editor1' flags='#PB_Editor_WordWrap' width='200' height='100'/>" +
	"	</window>" +
	"</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)


If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
	Define editor = DialogGadget(dlg_window1, "editor1")
	
	; Damn, that doesn't work
	Define Style = GetWindowLong_(GadgetID(editor), #GWL_STYLE)
	Style | #ES_DISABLENOSCROLL
	SetWindowLong_(GadgetID(editor), #GWL_STYLE, Style)
	
	SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf


Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Editor/RTF control styling (Windows)

Post by RASHAD »

Hi

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'>" +
   "      <editor name='editor1' flags='#PB_Editor_WordWrap' width='200' height='100'/>" +
   "   </window>" +
   "</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)


If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
   Define editor = DialogGadget(dlg_window1, "editor1")
   ; Damn, that doesn't work
  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
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Editor/RTF control styling (Windows)

Post by falsam »

ShowScrollBar_(GadgetID(editor), #SB_VERT, 1) ?

Code: Select all

EnableExplicit

Global dlg_window1 = CreateDialog(#PB_Any)
Global DialogsXML$ = #Empty$

Global Editor

DialogsXML$ +
"<dialogs>" +
"   <window name='window1' minwidth='210' minheight='110' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget| #PB_Window_ScreenCentered'>" +
"      <editor name='editor1' flags='#PB_Editor_WordWrap' width='200' height='100'/>" +
"   </window>" +
"</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)

Declare onEditorResize()

If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
  editor = DialogGadget(dlg_window1, "editor1")  
  SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf

BindGadgetEvent(editor, @onEditorResize())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Procedure onEditorResize()
  ShowScrollBar_(GadgetID(editor), #SB_VERT, 1)
EndProcedure

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Editor/RTF control styling (Windows)

Post by Lunasole »

falsam wrote:ShowScrollBar_(GadgetID(editor), #SB_VERT, 1) ?
Omg, so simple. Didn't even though of it (while already looked to those ScrollBar_ apis).
Thanks a lot ^^

@RASHAD, already tried that, it would be fine if only want to remove scrollbar completely (and won't work if trying to always show it).
However it should also work if used as in falsam's code.
Last edited by Lunasole on Fri Jul 28, 2017 8:17 pm, edited 1 time in total.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Editor/RTF control styling (Windows)

Post by falsam »

■ Without BindGadgetEvent()

Code: Select all

<editor name='editor1' flags='#PB_Editor_WordWrap' width='200' height='100' onEvent='onEditorResize()' />"
Code

Code: Select all

EnableExplicit

Global dlg_window1 = CreateDialog(#PB_Any)
Global DialogsXML$ = #Empty$

Global Editor

DialogsXML$ +
"<dialogs>" +
"   <window name='window1' minwidth='210' minheight='110' flags='#PB_Window_SystemMenu|#PB_Window_SizeGadget| #PB_Window_ScreenCentered'>" +
"      <editor name='editor1' flags='#PB_Editor_WordWrap' width='200' height='100' onEvent='onEditorResize()' />" +
"   </window>" +
"</dialogs>"
Define DialogsXML = ParseXML(#PB_Any, DialogsXML$)

Declare EditorResize()

Runtime Procedure onEditorResize()
  EditorResize()
EndProcedure

If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
  editor = DialogGadget(dlg_window1, "editor1")  
  SetGadgetText(editor, ~"11111111111111111111111111111111\n22222222222222222222222222222222\n\n\n\n\n\n\n")
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Procedure EditorResize()
  ShowScrollBar_(GadgetID(editor), #SB_VERT, 1)
EndProcedure
I don't like :mrgreen:

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
Post Reply