Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Storing Rich Text

Posted on 2001-06-29
6
Medium Priority
?
314 Views
Last Modified: 2010-04-06
Currently I am using a OLE object to initiate a Word Document.  Once this is launched the user types it's information and then from there needs to post it info to a database (rich text and all).  Is there any way you can store rich text in a record and be able to retrieve it in that same format back into an OLE object?  I know you can use a TDBRichEdit but for my purposes it doesn't have the functionality that Microsoft Word does.  What data type do you use in ORACLE to store the data?  And is there a way you can insert directly from the OLE object?

Thanks
0
Comment
Question by:nkrueger
[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
6 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6237919
TDBRichEdit is made for this purpose...
0
 
LVL 1

Expert Comment

by:trex_fire
ID: 6238457
What are the functionnalities the DBRichEdit won't offer you??
0
 

Author Comment

by:nkrueger
ID: 6238493
I need the capability to use auto text, auto corrects, the ability to add specific dictionary terms (in my case medical terms), etc.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Expert Comment

by:edey
ID: 6238621
Also, richEdit is really a kind of markedup text (sorta like html).  if you display richtext in a memo you'll get all kinds of "extra" char's - but you _can_ display & edit it.  Load it into a richEdit & you'll get formatted text.  In short you should be ok to save the resulting richText as plain text - just be shure to use a richText capable control to display it.

GL
Mike
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6240606
you can use a blob field in oracle and store the worddocument as is there

you can use ole or shellexecute(needs a file) to let edit the serverapplication the content
(which, must be stored also in the db)

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 6240618
a bit older sample (provided by simonet) using ole with paradox as database,
but this may applyable to all databases,
which are provding blobs,
even it supports any ole-serverapplication

unit uOleDbMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtnrs, ExtCtrls, Db, DBTables, DBCtrls, ComCtrls, ToolWin, Grids,
  DBGrids, ImgList;

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    Panel2: TPanel;
    Panel3: TPanel;
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    DBNavigator1: TDBNavigator;
    Table1: TTable;
    DataSource1: TDataSource;
    Splitter1: TSplitter;
    ScrollBox1: TScrollBox;
    OleContainer1: TOleContainer;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ImageList1: TImageList;
    DBGrid1: TDBGrid;
    OpenDialog1: TOpenDialog;
    Table1Description: TStringField;
    Table1OriginalFileName: TStringField;
    Table1FileTypeDescription: TStringField;
    Table1OleData: TBlobField;
    Table1OleClassName: TStringField;
    procedure OleContainer1ObjectMove(OleContainer: TOleContainer;
      const Bounds: TRect);
    procedure Table1NewRecord(DataSet: TDataSet);
    procedure FormResize(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure OleContainer1Deactivate(Sender: TObject);
    procedure Table1AfterScroll(DataSet: TDataSet);
  private
     function IsObjectEmpty : boolean;
    procedure SaveFileToBlob(fName : string);
    procedure LoadOLE;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ShellAPI;

procedure TForm1.OleContainer1ObjectMove(OleContainer: TOleContainer;
  const Bounds: TRect);
begin
  OleContainer1Deactivate(self);
end;

procedure TForm1.Table1NewRecord(DataSet: TDataSet);
begin
  OleContainer1.DestroyObject;

end;

procedure TForm1.LoadOLE;
var
  bs : TBlobStream;
begin
  if table1.fieldbyname('OleClassName').asstring<>'' then
  begin
     bs := TblobStream.create(Table1OleData, bmRead);
     try
        OleContainer1.CreateObject(table1.fieldbyname('OleClassName').asstring, false);
        OleContainer1.LoadFromStream(bs);
     finally
        bs.free;
     end;
  end;
end;


procedure TForm1.FormResize(Sender: TObject);
begin
  OleContainer1.Top := 0;
  OleContainer1.Left := 0;
end;

procedure TForm1.SaveFileToBlob(fName : string);
var
  bs : TBlobStream;
  sh : TSHFileInfo;
begin
  SHGetFileInfo(pchar(fNAme), 0, sh, sizeof(sh), SHGFI_TYPENAME );
  Table1.FieldByName('FileTypeDescription').asstring := sh.szTypeName;
  Table1.FieldByName('OriginalFileName').asstring := fName;
  Table1.FieldByName('OleClassName').asstring := OleContainer1.OleClassName;
  bs := TBlobStream.Create(Table1OleData, bmWrite      );
  Olecontainer1.SaveToStream(bs);
  bs.free;
  exit;
end;


procedure TForm1.ToolButton1Click(Sender: TObject);
var
  fName : string;
begin
 if IsObjectEmpty then
 begin
     if OpenDialog1.Execute then
     begin
        fName := uppercase(ExpandFileName(OpenDialog1.FileName));
        OleContainer1.CreateObjectFromFile(fName, false);
        OleContainer1.Top := 0;
        OleContainer1.left := 0;
     end;
     with Table1 do
     begin
        try
           edit;
        except
           append;
        end;
        SaveFileToBlob(fName);
        while OleContainer1.State<>osLoaded do
           application.processMessages;
        post;
     end;
  end;
end;

function TForm1.IsObjectEmpty : boolean;
begin
  Result := Table1.fieldbyname('OleData').IsNull;
  if (not Result) then
     Result := (Application.messageBox('This record already contains an OLE object. Would you like to overwrite it?', pchar(Application.title), MB_ICONQUESTION + MB_YESNO) = IDYES);
end;

procedure TForm1.OleContainer1Deactivate(Sender: TObject);
var
  bs : tBlobStream;
begin
  Table1.edit;
  bs := TBlobStream.create(Table1OleData, bmWrite);
  Olecontainer1.SaveToStream(bs);
  bs.free;
  Table1.post;
  OleContainer1.Top := 0;
  OleContainer1.Left := 0;
end;

procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
begin
  try
    LoadOLE;
  except
    // do nothing
  end;
end;

end.

meikl ;-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

636 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