Page 1 of 1
PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Thu Dec 14, 2023 5:06 am
by offsides
With my track record, I am hesitant to call anything a bug, any more. But after a recent PB upgrade to 6.04 from 6.01, my RTF project suddenly stopped working. The problem is that 6.04 appears to not recognize the rtf prolog as being rtf, just text. Ordinarily, when the EditorGadget is handed text with "\rtf1" in the first 6 chrs, it renders it accordingly.
I have done clean, identical, installs of PB 6.04, 6.02, and 6.01. The only one of the three that properly renders rtf on my machine is PB 6.01.
"My Machine" is a 2 year old HP running Win10, 32gb/1tb memory.
Here's something to try on your computer:
Code: Select all
Msg$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" +
"{\*\generator Riched20 10.0.19041}\viewkind4\uc1 " +
"\pard\sa200\sl276\slmult1{\f0\fs22 " +
"{\b This is a test rtf} to demonstrate\line " +
"\i PureBasic 6.04 doesn't do rtf.\i0\line " +
"\b PureBasic 6.02, also doesn't.\b0\line " +
"\b\i But PureBasic 6.01 DOES.\i0\b0 }}"
If OpenWindow(#PB_Any, 0, 0, 250, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Ed = EditorGadget(#PB_Any, 5, 5, 240, 250, #PB_Editor_ReadOnly)
SetGadgetText(Ed, Msg$)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
I'd be interested to hear what the forum sees on their systems.
Thanks,
Bill
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Thu Dec 14, 2023 5:27 am
by jacdelad
Code: Select all
Msg$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" +
"{\*\generator Riched20 10.0.19041}\viewkind4\uc1 " +
"\pard\sa200\sl276\slmult1{\f0\fs22 " +
"{\b This is a test rtf} to demonstrate\line " +
"\i PureBasic 6.04 doesn't do rtf.\i0\line " +
"\b PureBasic 6.02, also doesn't.\b0\line " +
"\b\i But PureBasic 6.01 DOES.\i0\b0 }}"
If OpenWindow(#PB_Any, 0, 0, 250, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Ed = EditorGadget(#PB_Any, 5, 5, 240, 250, #PB_Editor_ReadOnly)
SendMessage_(GadgetID(Ed), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
SetGadgetText(Ed, Msg$)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
https://www.purebasic.fr/english/viewtopic.php?t=81402
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Thu Dec 14, 2023 5:33 am
by offsides
Many thanks, jacdelad. I totally missed that.
Thanks also for the quick reply!
Bill
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Thu Dec 14, 2023 6:12 am
by jacdelad
To be fair, I knew about the problem and knew there was a simple solution with a single API call to fix that, but I still needed some minutes to find the solution. It's not easy to spot (or I'm dumb).
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Thu Dec 14, 2023 4:56 pm
by Axolotl
Unfortunately, this feature of the EditorGadget() has been changed without notice. (... so all old RTF examples in the forum are not working anymore)
The corresponding entry in the help is definitely missing.
There should at least be something in the history. I would also like to see a note under EditorGadget().
P.S. How do you actually get to the history page in the online help?
hmmm, I always have to code something....
Code: Select all
Procedure main()
If OpenWindow(0, 0, 0, 280, 64, "Show Help Page History", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
StickyWindow(0, 1) ; small windows should be on top :)
TextGadget(0, 0, 0, 280, 64, "Show the PureBasic Help Page History" + #LF$ + "Close this window to get rid of the help as well.", #PB_Text_Center)
OpenHelp(#PB_Compiler_Home + "PureBasic.chm", "MainGuide/history.html")
Repeat ; main loop
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break ; say bye.
EndSelect
ForEver ; main loop
CloseHelp()
EndIf
ProcedureReturn 0
EndProcedure
End main()
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Fri Dec 15, 2023 4:38 am
by offsides
Not wanting to beat a dead horse, at least not too much, I do ask:
Presumably the Linux and IOS PB editions are unchanged and automatically render rtf when they see it. If it takes an API call to fix the Windows version, can the call be built into the EditorGadget?
...and the Windows version is restored to the way it was and all those rtf applications out there don't have to be amended.
Just a thought
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Fri Dec 15, 2023 4:49 am
by jacdelad
There already was a discussion, but I neither remember the thread, nor the outcome. I guess Fred has his reasons.
In the meantime you can include the following code near the top (or an include, however, it must be placed before any EditorGadget is created) to restore the old behaviour automatically:
Code: Select all
CompilerIf #PB_Compiler_OS=#PB_OS_Windows
Procedure __EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
If iGadget=#PB_Any
iGadget=EditorGadget(#PB_Any,iX,iY,iWidth,iHeight,iFlags)
Else
EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
EndIf
If IsGadget(iGadget)
SendMessage_(GadgetID(iGadget), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
EndIf
ProcedureReturn iGadget
EndProcedure
Macro EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags=0)
__EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
EndMacro
CompilerEndIf
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Fri Dec 15, 2023 4:58 am
by offsides
jacdelad
I just insert the SendMessage_ .... after creating the EditorGadget. PB 6.04 now works fine.
Thanks for your input on this.
Bill
Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Fri Dec 15, 2023 5:14 am
by jacdelad
I assumed you wanted a more automated version for more projects (see your last post). However, both are fine and do basically the same.

Re: PureBasic 6.04 and 6/02 RTF "Issue"
Posted: Sat Dec 16, 2023 5:19 am
by offsides
Thanks, Jacdelad.
I'll likely use them both.