?
Solved

Rtf into Richedit component

Posted on 2004-10-12
12
Medium Priority
?
903 Views
Last Modified: 2013-11-22
Hello there,

I have a large rtf document (file) that I want to put into a RichEdit component - but I want it in there at design time - so I open the rtf document in word - it's laid out nicely. I then copy and then paste into the rtf document (under lines on the object inspector) but it loses all the formating.

So, how can I keep I get that data in there at design time?

Cheers
Nick
0
Comment
Question by:wildzero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 10

Author Comment

by:wildzero
ID: 12295092
Solved it by opening the file rtf in note pad, copying all the stuff
Then when I add the stuff to the richedit I click code editor and paste it there

sweeet!
0
 
LVL 10

Author Comment

by:wildzero
ID: 12295094
Ahh shoot
it comes out fine then in design view
but when I run the program, it's plain txt.
Pos
0
 
LVL 10

Author Comment

by:wildzero
ID: 12295642
Points increased
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Assisted Solution

by:DragonSlayer
DragonSlayer earned 200 total points
ID: 12295673
you may
1. embed it in a resource file, then load it dynamically during runtime
2. load it from an external file during runtime
0
 
LVL 10

Author Comment

by:wildzero
ID: 12296192
Load it dynamically?
Do tell :) Points have been risen, again for a good reply ;)
0
 
LVL 6

Accepted Solution

by:
david_barker earned 400 total points
ID: 12296369
From http://www.swissdelphicenter.ch/en/showcode.php?id=1049
Autor: Thomas Stutz

(*
  Load RTF file from resource:

  You can store any kind of file as a RCDATA resource.
  The following example shows this with an RTF file.

  Create a text file called textres.rc and put the
  following line in it:

  TESTDOC RCDATA "textdoc.rtf"

  Next, compile that using the Borland Resource Compiler,
  which is provided with Delphi.

  brcc32.exe textres.rc
   
  Your next step is to include the compiled resource (.RES) file into
  your executable, which can be done with the {$R} compiler directive.

*)


implementation

{$R *.dfm}
{$R textres.res}  // <---- your resource file!

procedure TForm1.Button1Click(Sender: TObject);
var
  rs: TResourceStream;
begin
  rs := TResourceStream.Create(hinstance, 'TESTDOC', RT_RCDATA);
  try
    Richedit1.PlainText := False;
    TempStream.Position := 0;
    Richedit1.Lines.LoadFromStream(rs);
  finally
    rs.Free;
  end;
end;


0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 12296817
darn, someone's faster :-p

and to load from external file:

RichEdit1.Lines.LoadFromFile('myrtffile.rtf');
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 12300031
Comment

The question was <<So, how can I keep I get that data in there at design time?>>

Not runtime...........

Two possible ways I can think of:

Create a component containing the RTF Component and populate it in code in the initialise event.

Put it in a database table and bind the RTF to the table field - this should dispay the RTF at designtime if the controls are active.


Voodooman

0
 
LVL 6

Expert Comment

by:david_barker
ID: 12300160
Voodoman,

In my solution, the data is in the application at design-time.
It's just it's not in the TRichEdit component but in the resource section of the .EXE
Even if it is not exactly what was initialy asked, I think it's the closest, because I assume the goal is to have the RTF in the application, and not in an outside file (or database).
And of course, my TForm1.Button1Click() could be replaced by the TForm1.OnCreate() event so that the process happens at application startup.

David
0
 
LVL 10

Author Comment

by:wildzero
ID: 12300199
Thats great, I will try it out soon
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 12303213
Hi David

No worries...

Another way of course would be to use something like EasyTable from www.aidaim.com.

This is a database product, but you can embed the database in the .exe.

You could then have any number of texts in the RTF - as many as were in the database.

You cannot of course edit the records or add to them.

This would be a very easy way as you would not have to use a resource file editor (or indeed no anything about resources!!!).

Like most people on EE, I comment only on interesting items (my 10 cents) an this was very interesting!!

Regards

Voodooman

0
 
LVL 6

Expert Comment

by:david_barker
ID: 12305363
Hi Voodoman,

I just rushed to read more about EasyTable. Interesting product, thanks for the tip !
Could be very useful in quite a few situations.

Regards,

David
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question