Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RTF tags

Status
Not open for further replies.

ajpa

Programmer
Jan 31, 2002
52
GB
What I'd like to do is to highlight a word or two in a text box and then convert just the highlighted bit to italics, say, or bold. The toolbar in the component gallery only changes the text attributes of the active control itself, thus affecting everything (and, anyway, I can't get it even to do that!). I wondered if there was any way of tagging the chosen words? Has anyone tried to do this with frx2any? I'm a bit loth to shell out $69 to have a look if it's not going to do the job.

Tony Ayres
 
Hi Tony,

The OLE RTFBox Control will do what you are asking. Would that work for you? It appears almost identical to the standard VFP TextBox control. The only difference (appearance-wise) is that its border is slightly different from the VFP textbox.

BillvV
 
BillvV,

How amazing to get a reply after all this time! Thank you.

What I eventually did was to use an ordinary text box, enter rtf tags manually as required, and then make the program assemble a full rtf file by stitching together all the various headers needed.

But your solution seems far more elegant and user-friendly. I'm not very good on OLE and will have to get better. In the meantime, I can't find the RTFBox Control in any of my lists. Any ideas on where it might be lurking?

Tony
 
Hi Tony,

You will find the RTF Control in the OLE list, when adding an OLE control. I am using VFP8, and here is what I do...

Drop an OLE control from the Control Panel to your form. At the time you place it on the form (at this stage it is a generic OLE control, without any name), The OLE Insert List appears with a list of the scads of ActiveX's available. You will find it under "Microsoft Rich Textbox Control, Ver 6.0. Select it and it's placed on the form.

But your work doesn't stop there, because in order to make the necessary manipulations to RTF text (e.g. bold, italic, indenting, centering, colored text, etc.), you will need controllers: buttons, options, font selector, etc.

There is good help for this in the VFP files. In mine I have two directories where they live:

C:\Program Files\Microsoft Visual Foxpro 8\Samples\Solution\OLE has a demo form (RTF.SCX) which has all the usual typographic controls and is enlightening to hack.

Also "C:\Program Files\Microsoft Visual Studio\Vfp98\RichText\RTFBOX98.CHM". This Help file has the most complete listing and documentation of RTF PEMs that I have seen anyplace.

So just getting the RTFBox onto the form is only half the job. But the good news is that once you have put together your controllers for it, they are available forever.

I like the RTF box control, and it does ALMOST everything I want. The only lack which is a nuisance in my usage, is the inability of RTF to produce a plain horizontal line in the text. HTML does this handily with its <hr> tag, but RTF is clueless about this.

I see I have a fellow-hair puller in the task of figuring out the RTF headers and tags and inserting them programmatically or manually. I went through the same thing, when I had to convert a WordPerfect file (heavily formatted) into RTF for importation into VFP. It took me days to get the RTF tags and headers straight and write the conversion code.

Best Regards,

Bill von Valtier
Rochester, Michigan
 
Don't forget to distribute the appropriate .OCX file so that you're users have the ActiveX control you're using, too!

See for details on determining what OCX/DLL a particular control uses. (btw: an .OCX file is basically just a .DLL file that conforms to a particular interface... that is, which implements the expected functions and classes)

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top