为什么要左键双击olecontainer之后才能显示word文档呢?procedure TForm1.Button1Click(Sender: TObject);
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(adotable1.FieldByName('PactText')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(adotable1.fieldbyname('DocName').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
//olecontainer1控件放在一个名字叫djhyopenform的窗体里
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;
var
sfilename:string;
bs:Tadoblobstream;
begin
bs:=Tadoblobstream.Create(TBLOBfield(adotable1.FieldByName('PactText')),bmread);
try
sfilename:=extractfilepath(application.ExeName)+trim(adotable1.fieldbyname('DocName').AsString);
sfilename:=sfilename+'.'+'doc';
bs.SaveToFile(sfilename);
try
//olecontainer1控件放在一个名字叫djhyopenform的窗体里
djhyopenform:=Tdjhyopenform.Create(self);
djhyopenform.olecontainer1.CreateObjectFromFile(sfilename,false);
djhyopenform.OleContainer1.Iconic:=true;
djhyopenform.ShowModal;
finally
djhyopenform.Free;
end;
finally
bs.free;
end;
end;
sfilename:=extractfilepath(application.ExeName)+trim(adotable1.fieldbyname('DocName').AsString);
这个DocName就是正打开文档的文件名。
{
返回临时文件夹目录路径
}
begin
SetLength(Result, GetTempPath(0, PChar(Result)));
ZeroMemory(PChar(Result), Length(Result));
GetTempPath(Length(Result), PChar(Result));
Result := PChar(Result);
end;