嗯-好象用OLE实现呀:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, OleCtnrs, ExtCtrls;
type
TOleF = class(TForm)
ole: TOleContainer;//TOleContainer, 它在delphi的system页!
Table1: TTable;
Panel1: TPanel;
Panel2: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
OleF: TOleF;
implementation
{$R *.DFM}
procedure TOleF.Button1Click(Sender: TObject);
var
oletest:Tstream;
begin
//新建OLE对象为用户编辑用
table1.open;
oletest:=table1.CreateBlobStream(table1.FieldbyName('blob'),bmread);
ole.CreateObject('word.document',false);
ole.DoVerb(ovshow);
oletest.free;
end;
procedure TOleF.Button2Click(Sender: TObject);
var stre:TMemoryStream;
begin
// ole对象中的内容写入到数据库中
table1.Edit;
table1.Append;
stre:=TMemoryStream.Create ;
ole.SaveToStream(stre);
TBlobField(table1.FieldbyName('blob')).LoadFromStream(stre);
ole.doverb(ovshow);
table1.post;
stre.free;
end;
procedure TOleF.Button3Click(Sender: TObject);
begin
ole.close; //关闭ole
end;
procedure TOleF.Button4Click(Sender: TObject);
begin
close; //退出本界面
end;
procedure TOleF.Button5Click(Sender: TObject);
VAR
oleDY:Tstream;
begin
//调用OLE对象为用户编辑用
table1.open;
table1.RecNo:=1;
oleDY:=table1.CreateBlobStream(table1.FieldbyName('blob'),bmread);
OLE.LoadFromSTREAM(OLEDY);
ole.DoVerb(ovshow);
oleDY.free;
end;
end.
存盘退出:
var Stre:tmemorystream;
begin
Stre:=TMemoryStream.Create ;
Ole.SaveToStream(stre);
Table1.edit;
TBlobField(Table1.FieldbyName('blob1')).LoadFromStream(stre)
Table1.post;
Stre.free;
Ole.close;
Form.close;
end;