在F1BOOK中插入一幅图象!(150分)

  • 主题发起人 主题发起人 hsw
  • 开始时间 开始时间
H

hsw

Unregistered / Unconfirmed
GUEST, unregistred user!
OBJNEWPICTURE 如何使用?
我使用后,总是说OLE错误???我传递的图形HANDLE 是OLECATIIN 的,用TMETAFILE的编译不通过?
请帮助!!工作问题!很急!
 
分坛主 houyg、lhz :
别人沉默,你们也沉默吗?
我曾经为大富翁付出了许多(900分专家分),都是我过年是
挣的,一直在封闭开发,不然也不止这分……
请分坛主 不要让我失望……
难道,没有人知道吗?我大哭………………
大富翁……大富翁……不在是delphi的乌托邦……
不在是我的避风港……
 
对不起,情绪太激动了…………
 
把错误信息打上来
 
没人知道吗 我再加200分
 
请原谅,我不太清楚你说的是什么?
 
>>liuchuanbo
太谢谢你了,如果问题解决的话,你占头功!
灌水有分!!
 
hsw,我也在用F1BOOK,菜鸟一只,能不能教教我如何传递一个
OLE_HANDLE类型的变量?

我在ASP网页里,打开数据库提出一个原来存在里头的VTS文件,
然后希望用ReadFromBlob函数读这个字段,但是该函数要求
OLE_HANDLE类型的参数,我根本就不知道怎么用这个类型。

不好意思,在这个时候倒向你请教了。我也单独提出问题了,有分。
呵呵。
 
附加功能 将问题提前
 
高手不要太保守吗
 
Formula One只支持WMF格式,而当Delphi处理MetaFile时会自动地将WMF转化为EMF,所以传
给objCreaetPicture函数的Handle实际是EMF格式的,Formula One不能处理,所以会出错。
解决办法是自己用API SetMetaFileBitsEx创建WMF格式的MetaFile.整理后的代码被我误删
了,以下是我做测试时的代码,关键步骤都有了,大家自己整理吧。

unit uCreatePic;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, AxCtrls, OleCtrls, TTF160_TLB;

const
WMFKey = Integer($9AC6CDD7);
WMFWord = $CDD7;

type
PMetafileHeader = ^TMetafileHeader;
TMetafileHeader = packed record
Key: Longint;
Handle: SmallInt;
Box: TSmallRect;
Inch: Word;
Reserved: Longint;
CheckSum: Word;
end;
TForm1 = class(TForm)
F16Book1: TF16Book;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function TestEmf(Stream: TStream):Boolean;
var
Form1: TForm1;

implementation

uses uMyUtils;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
MetaStream: TMemoryStream;
hWMF: HMETAFILE;
BitMem: Pointer;
nLength: LongInt;
begin
MetaStream := TMemoryStream.Create;
try
MetaStream.LoadFromFile('c:/temp/VDT1.wmf');

if TestEmf(MetaStream) then
begin
MetaStream.Seek(SizeOf(TEnhMetaHeader),soFromBeginning);
nLength := MetaStream.Size - SizeOf(TEnhMetaHeader);
End
else
begin
MetaStream.Seek(SizeOf(TMetaFileHeader),soFromBeginning);
nLength := MetaStream.Size - SizeOf(TMetaFileHeader);
end;

GetMem(Bitmem, nLength);
try
MetaStream.Read(Bitmem^,nLength);
hWMF := SetMetaFileBitsEx(nLength,Bitmem);

if hWMF = 0 then
begin
ShowMessage('aaaa');
Exit;
End;

F16Book1.ObjCreatePicture(0,0,1,5,hWMF,8,0,0);
finally // wrap up
FreeMem(Bitmem,nLength);
end
// try/finally
finally // wrap up
MetaStream.Free;
MetaStream := nil;
end
// try/finally
end;

function TestEmf(Stream: TStream):Boolean;
var
Size: Longint;
Header: TEnhMetaHeader;
begin
Size := Stream.Size - Stream.Position;
if Size > Sizeof(Header) then
begin
Stream.Read(Header, Sizeof(Header));
Stream.Seek(-Sizeof(Header), soFromCurrent);
end;
Result := (Size > Sizeof(Header)) and
(Header.iType = EMR_HEADER) and (Header.dSignature = ENHMETA_SIGNATURE);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
MetaStream: TMemoryStream;
begin
MetaStream := TMemoryStream.Create;
try
MetaStream.LoadFromFile('c:/temp/37100000099102601996.emf');
DrawF1Picture(MetaStream,F16Book1);
Finally
MetaStream.Free;
MetaStream := nil;
End;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
ShowMessage(IntToStr(SizeOf(TEnhMetaHeader))+' '+ IntToStr(SizeOf(TMetaFileHeader)));
end;

end.
 
Formula One只支持WMF格式,而当Delphi处理MetaFile时会自动地将WMF转化为EMF,所以传
给objCreaetPicture函数的Handle实际是EMF格式的,Formula One不能处理,所以会出错。
解决办法是自己用API SetMetaFileBitsEx创建WMF格式的MetaFile.整理后的代码被我误删
了,以下是我做测试时的代码,关键步骤都有了,大家自己整理吧。

unit uCreatePic;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, AxCtrls, OleCtrls, TTF160_TLB;

const
WMFKey = Integer($9AC6CDD7);
WMFWord = $CDD7;

type
PMetafileHeader = ^TMetafileHeader;
TMetafileHeader = packed record
Key: Longint;
Handle: SmallInt;
Box: TSmallRect;
Inch: Word;
Reserved: Longint;
CheckSum: Word;
end;
TForm1 = class(TForm)
F16Book1: TF16Book;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function TestEmf(Stream: TStream):Boolean;
var
Form1: TForm1;

implementation

uses uMyUtils;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
MetaStream: TMemoryStream;
hWMF: HMETAFILE;
BitMem: Pointer;
nLength: LongInt;
begin
MetaStream := TMemoryStream.Create;
try
MetaStream.LoadFromFile('c:/temp/VDT1.wmf');

if TestEmf(MetaStream) then
begin
MetaStream.Seek(SizeOf(TEnhMetaHeader),soFromBeginning);
nLength := MetaStream.Size - SizeOf(TEnhMetaHeader);
End
else
begin
MetaStream.Seek(SizeOf(TMetaFileHeader),soFromBeginning);
nLength := MetaStream.Size - SizeOf(TMetaFileHeader);
end;

GetMem(Bitmem, nLength);
try
MetaStream.Read(Bitmem^,nLength);
hWMF := SetMetaFileBitsEx(nLength,Bitmem);

if hWMF = 0 then
begin
ShowMessage('aaaa');
Exit;
End;

F16Book1.ObjCreatePicture(0,0,1,5,hWMF,8,0,0);
finally // wrap up
FreeMem(Bitmem,nLength);
end
// try/finally
finally // wrap up
MetaStream.Free;
MetaStream := nil;
end
// try/finally
end;

function TestEmf(Stream: TStream):Boolean;
var
Size: Longint;
Header: TEnhMetaHeader;
begin
Size := Stream.Size - Stream.Position;
if Size > Sizeof(Header) then
begin
Stream.Read(Header, Sizeof(Header));
Stream.Seek(-Sizeof(Header), soFromCurrent);
end;
Result := (Size > Sizeof(Header)) and
(Header.iType = EMR_HEADER) and (Header.dSignature = ENHMETA_SIGNATURE);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
MetaStream: TMemoryStream;
begin
MetaStream := TMemoryStream.Create;
try
MetaStream.LoadFromFile('c:/temp/37100000099102601996.emf');
DrawF1Picture(MetaStream,F16Book1);
Finally
MetaStream.Free;
MetaStream := nil;
End;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
ShowMessage(IntToStr(SizeOf(TEnhMetaHeader))+' '+ IntToStr(SizeOf(TMetaFileHeader)));
end;

end.
 
接受答案了.
 
后退
顶部