whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
...load Rft Text from a resource file into a TRichEdit?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (17):  
     


(*
  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.

*)

(*

  Man kann eine beliebige Datei als RCDATA Ressource in eine
  Exe-Datei einbinden.
  Das folgende Beispiel zeigt, wie man einen RTF-Text aus
  einer Ressource lädt und in einem TRichEdit anzeigt.

  Erstelle zuerst eine Datei "textres.rc" mit folgendem Inhalt:

  TESTDOC RCDATA "textdoc.rtf"

  Kompiliere diese mit brcc32.exe:

  brcc32.exe textres.rc
  
  Es wurde nun eine textres.res Datei erzeugt.

*)


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;




 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners