Page 1 of 1

CatchRTF()

Posted: Tue Sep 30, 2003 9:30 pm
by freak
Code updated For 5.20+

This Procedure let's you include a RTF file with IncludeBinary, and then
directly catch it, and load it into an EditorGadget.

Usefull if you want to make a static Text box, with nicely formated text for
example.

Code: Select all

; Usage:
; CatchRTF(#EditorGadget, MemoryAddress)
;
; Streams a RTF file included by IncludeBinary directly into an EditorGadget.
;
;
Procedure.l CatchRTF_Callback(dwCookie.l, pbBuff.l, cb.l, *pcb.LONG)
  Shared CatchRTF_Address.l
  CopyMemory(CatchRTF_Address, pbBuff, cb)
  CatchRTF_Address + cb
  *pcb\l = cb
  ProcedureReturn 0
EndProcedure
;
Procedure CatchRTF(Gadget.l, MemoryAddress.l)
  Shared CatchRTF_Address.l
  CatchRTF_Address = MemoryAddress
  stream.EDITSTREAM\pfnCallback = @CatchRTF_Callback()
  SendMessage_(GadgetID(Gadget), #EM_STREAMIN, #SF_RTF, @stream)
EndProcedure   
Timo

Blank RTF EditorGadget on NT 4

Posted: Wed Oct 01, 2003 11:00 am
by Andy
Nice work!

One question about that:

I have integrate it in my program and it works fine - on all Windows except one Windows NT 4 - there appears only a blank EditorGadget. I have test it on another NT - there it works again... :x

Have anybody an idea, what could be the reason, why it works not on that Windows NT?

Best Regards
Andy

Posted: Wed Oct 01, 2003 11:57 am
by Rings
install a IE 5.5 or higher

Posted: Wed Oct 01, 2003 12:47 pm
by Andy
There is a version 6 installed on this NT and all urgent Windows Updates too...

Posted: Wed Oct 01, 2003 4:49 pm
by Karbon
Just out of curiosity - what's the difference in this and just using setgadgettext() to fill the gadget?

Posted: Wed Oct 01, 2003 7:36 pm
by freak
A RTF file looks like this:

Code: Select all

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe3082\deftab708{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}{\f1\fmodern\fprq1\fcharset0 Courier New;}{\f2\froman\fprq2\fcharset0 AGaramond;}{\f3\froman\fprq2\fcharset0 Times New Roman;}}
{\colortbl ;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;}
... now if you use SetGadgetText() with that, it might look a bit ugly :wink:

The point is, that you can not just put plain text inside (with SetGadgetText),
but a nicely formated RTF file, with lots of colors, fonts and sizes.

Basically, i wanted to include a little help-box in my app, and didn't want to
store anything in an extra file. This was the best way to go.

Timo

Posted: Thu Oct 02, 2003 2:02 am
by Karbon
Oooooooh. Mmmmkay.

I guess maybe I was thinking the editor gadget interpreted what ever rich text you slapped into it..

Thanks freak!

Posted: Thu Oct 02, 2003 10:08 am
by GedB
Perhaps adding an RTF flag to the set GADGETTEXT command would be a nice addition to the langauge?

Posted: Sat Jun 24, 2006 6:33 pm
by Joakim Christiansen
GedB wrote:Perhaps adding an RTF flag to the set GADGETTEXT command would be a nice addition to the langauge?
That would be so sexy!
You could copy it into another editor gadget like this:

Code: Select all

String.s = GetGadgetText(#Editor,#PB_Editor_RTF)
SetGadgetText(#Editor2,String,#PB_Editor_RTF)
And it's usefull for much more!