Code: Select all
Heres the code:
; PureBasic Visual Designer v3.70a Beta
;- Window Constants
;
#Window_0 = 0
;- Gadget Constants
;
#Gadget_1 = 0
#original = 1
#start = 2
Procedure Open_Window_0()
If OpenWindow(#Window_0, 402, 160, 293, 79, "test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Window_0))
TextGadget(#Gadget_1, 10, 10, 100, 30, "Enter String and select a piece:")
EditorGadget(#original, 110, 10, 170, 133)
ButtonGadget(#start, 10, 40, 70, 20, "make bold")
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
If event = #PB_Event_Gadget And EventGadget() = #start
original.s = GetGadgetText(#original) ; get strings from Gadget
new.s = ""
; get selected position from #original Gadget
SendMessage_(GadgetID(#original), #EM_GETSEL, @startpos.l, @endpos.l)
new = Left(original, startpos) ; unselected part on the left
new + "<B>" ; bold mark
new + Mid(original, startpos+1, endpos-startpos) ; marked text
new + "</B>" ; unbold mark
new + Right(original, Len(original)-endpos) ; unselected part on the right
SetGadgetText(#original, new) ; set new text
; set selection again (3 characters right of original position, because we
; added the <b>
SendMessage_(GadgetID(#original), #EM_SETSEL, startpos+3, endpos+3)
setActiveGadget(#original) ; activate Gadget again
EndIf
Until Event = #PB_Event_CloseWindow
End
Try typing this in the box:
fdsfdsfjkdjsla
fjdsklfjdsl
dsada
And then put your cursor between s and a on the last line
and try entering the bold stuff
doesn't work right here...
I get:
jkjkl
jkl
<B></B>
hjk