CatchRTF()

Share your advanced PureBasic knowledge/code with the community.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

CatchRTF()

Post 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
quidquid Latine dictum sit altum videtur
Andy
User
User
Posts: 18
Joined: Wed Jun 18, 2003 8:32 pm
Location: Switzerland

Blank RTF EditorGadget on NT 4

Post 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
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

install a IE 5.5 or higher
SPAMINATOR NR.1
Andy
User
User
Posts: 18
Joined: Wed Jun 18, 2003 8:32 pm
Location: Switzerland

Post by Andy »

There is a version 6 installed on this NT and all urgent Windows Updates too...
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Just out of curiosity - what's the difference in this and just using setgadgettext() to fill the gadget?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Oooooooh. Mmmmkay.

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

Thanks freak!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Perhaps adding an RTF flag to the set GADGETTEXT command would be a nice addition to the langauge?
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post 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!
I like logic, hence I dislike humans but love computers.
Post Reply