Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ammar Hadi
  Where is Ammar Hadi?
 Al-Samawah
 Iraq
 Ammar Hadi
 To: Arvin Mendoza
  Where is Arvin Mendoza?
 The Fort
 Philippines
 Arvin Mendoza
 Tags
Subject: RE: TXT to RTF format
Thread ID: 228748 Message ID: 228758 # Views: 4 # Ratings: 0
Version: Visual FoxPro 9 Category: Active X Controls & OLE Automation
Date: Thursday, May 21, 2009 11:10:23 AM         
   


> Dear Friends,
>
> I need you help!
>
> How to convert a simple text file into an RTF format? I have a memo field and I want to convert the content with RTF tags.
>
> Sample text: THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG NEAR THE BANK OF THE RIVER.
>
>
> Thank you very much!
>
> Regards,
>
>
> Arvin P. Mendoza
> MCMXIV,Mizrach

Hi Arvin,

If I you want to save this formatted text:
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG NEAR THE BANK OF THE RIVER,

it should be saved in your field like this:

{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fswiss\fcharset178{\*\fname Arial;}Arial (Arabic);}}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\ltrpar\lang1033\f0\fs20 THE QUICK \b BROWN\b0 FOX JUMPED \i OVER\i0 THE LAZY \ul DOG\ulnone NEAR THE BANK OF THE RIVER\lang1025\f1\rtlch\par}

But how you can do that?

You can Add a richtext activex control into your form.

see this example:

PUBLIC myForm

myForm=CREATEOBJECT("Form1")

myForm.SHOW(1)

DEFINE CLASS form1 AS FORM
  WIDTH=470
  HEIGHT=347
  CAPTION="using the richtext"

  ADD OBJECT edtRich AS OLECONTROL WITH;
    OLECLASS="RICHTEXT.RichtextCtrl.1",;
    WIDTH=168,;
    HEIGHT=156

  ADD OBJECT cmdBold AS COMMANDBUTTON WITH;
    WIDTH=84,;
    HEIGHT=27,;
    TOP=160,;
    CAPTION="B"

  PROCEDURE cmdBold.CLICK
    THISFORM.edtRich.selBold=!THISFORM.edtRich.selBold
  ENDPROC

  ADD OBJECT cmdItalic AS COMMANDBUTTON WITH;
    WIDTH=84,;
    HEIGHT=27,;
    TOP=160,;
    LEFT=90,;
    CAPTION="I"

  PROCEDURE cmdItalic.CLICK
    THISFORM.edtRich.selItalic=!THISFORM.edtRich.selItalic
  ENDPROC

  ADD OBJECT cmdLoad AS COMMANDBUTTON WITH;
    WIDTH=84,;
    HEIGHT=27,;
    LEFT=170,;
    CAPTION="Load"

  PROCEDURE cmdLoad.CLICK
    GO TOP IN tempRich
    THISFORM.edtRich.textrtf=tempRich.myText
  ENDPROC

  ADD OBJECT cmdSave AS COMMANDBUTTON WITH;
    WIDTH=84,;
    HEIGHT=27,;
    LEFT=170,;
    TOP=40,;
    CAPTION="Save"

  PROCEDURE cmdSave.CLICK
    MESSAGEBOX("The memo will contain:"+CHR(13)+THISFORM.edtRich.textrtf)
    GO TOP IN tempRich
    REPLACE myText WITH THISFORM.edtRich.textrtf IN tempRich
  ENDPROC

  PROCEDURE LOAD
    CREATE CURSOR tempRich(myText m)
    INSERT INTO tempRich VALUES ("THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG NEAR THE BANK OF THE RIVER.")
  ENDPROC

  PROCEDURE UNLOAD
    SELECT tempRich
    USE
  ENDPROC

ENDDEFINE


here you can load and save data into a cursor with rtf characters included.

Hope this helps

Added idea: You even can do this job automatically by hiding the richtext box load the data into the richtext and automating the process of formating in code and re-save the data into the memo.

Ammar Hadi ................IRAQ

My Foxite Weblog

---------------
I I I really love foxite
___________________________

ENTIRE THREAD

TXT to RTF format Posted by Arvin Mendoza @ 5/21/2009 9:42:29 AM
RE: TXT to RTF format Posted by Ammar Hadi @ 5/21/2009 11:10:23 AM
RE: TXT to RTF format Posted by Yousfi Benameur @ 5/22/2009 10:07:55 AM
RE: TXT to RTF format Posted by Yousfi Benameur @ 5/22/2009 12:15:42 PM