EditorGadget is not designed to work with RTF. It's only for plain text.Armoured wrote: But why not to have a basic command to make this?![]()
The code to convert is useless on macos or linux.
// edit
It's better not using of string to hold the ascii string. I think this one
should better in this case:
Code: Select all
Procedure SetASCIIText(Gadget, Text.s)
Protected *mem, result
If Text
*mem = AllocateMemory(StringByteLength(Text, #PB_Ascii) + 1)
If *mem
PokeS(*mem, Text, -1, #PB_Ascii)
result = SendMessage_(GadgetID(Gadget), #WM_SETTEXT, 0, *mem)
FreeMemory(*mem)
EndIf
EndIf
ProcedureReturn result
EndProcedure
OpenWindow(0, 200, 200, 400, 200,"Memory Put", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget)
EditorGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), #PB_Editor_ReadOnly)
SendMessage_(GadgetID(0), #EM_LIMITTEXT, -1, 0)
a.s="{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0 Arial;}}{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;}"
a.s=a.s+"{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello, this is \cf1\b\fs32 RTF\cf2\b0\fs20 direct!\cf0\par}"
SetASCIIText(0, a)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow