F1BOOK我又遇到新问题?(objcreatepictuer函数)(50分)

  • 主题发起人 主题发起人 xxxyyyuuu
  • 开始时间 开始时间
X

xxxyyyuuu

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在f1book中加入图片,就像他带的例子(object文件夹),也就是objcreatepictuer函数
怎么用,特别是hMF参数,望赐教!!!我写的代码:
TMetafile *pMetafile = new TMetafile;
TMetafileCanvas *pCanvas = new TMetafileCanvas(pMetafile, 0);
pCanvas->Brush->Color = clRed;
pCanvas->Pen->Color=clGreen;
pCanvas->Ellipse(0,0,100,100);
pCanvas->LineTo(50,50);
delete pCanvas;
//if (OpenDialog1->Execute())
//Image1->Picture->LoadFromFile(OpenDialog1->FileName);
Image1->Canvas->Draw(0,0,pMetafile);
OLE_HANDLE hmf=Image1->Picture->Metafile->Handle;
F1Book11->ObjCreatePicture(1, 7, 4, 2, hmf, 8, 12, 12);
另外:workbook之间能调用数据吗??(最好有例子)
 
难道就没人会吗?
 
你说的这个控件哪里有下载????
 
机器上没装VB,遗憾
 
1. 真的很奇怪. 我在VB中用ObjCreatePicture函数,用的很顺利,但是在Delphi中
将hMF := Image1.picture.metafile.handle,却出现'invalide argument'错误.
看了F1Book的新闻组,发现有人在VC中也出现这种情况.
VB中代码为:
Image1.Picture = LoadPicture("c:/windows/marble.wmf") ' Load metafile into control
F1Book1.ObjNewPicture 1, 2, 4, 12, id&, Image1.Picture, 8, 0, 0

2. workbook之间当然可以能调用数据,注意一下F1Book的SS属性.
另外如Attach, AttachToSS等方法都是workbook之间调用数据的高级用法,
至于F1Book1.TextRC[i,j] := F1Book2.TextRC[ii,jj]是比较低级的用法了.
关于AttachToSS的一个最典型例子(VB)如下:
Sub SwapViews (toWhat As Integer)
Select Case toWhat
Case kRegionSales
F1BookMain.AttachToSS F1BookHidden1.SS
Case kDistrictSales
F1BookMain.AttachToSS F1BookHidden2.SS
Case kNationalSales
F1BookMain.AttachToSS F1BookHidden3.SS
Case Else
MsgBox "debug: invalid toWhat in SwapViews # " &amp
toWhat
End Select
End Sub
因为F1Book是用C实现的,所以在数据的存储和处理上引用了Doc/View的思想,
Attach或AttachToSS是这种思想的体现.
 
to jack9999:好像www.51delphi.com里有下的,名称不太清楚了。这个控件是formula one6.o
是表格控件。你自己找找吧!
to bluerain:Attach, AttachToSS这样的函数我试了一下,情况如下:
我在form上放了两个f1book控件1、2,用AttachToSS将1的sheet视图调到2上显示成功了,
但原来2上的sheet却没了,如果我想同时显示1,2的sheet在2中就无法做到了?你认为该怎么做?

 
那就没办法了.只有用CopyRangeEx了.
例如F1Book61 有 n1个sheet
F1Book62有n2个sheet.

n1 := F1Book61.NumSheets;
n2 := F1Book62.NumSheets;
F1Book62.NumSheets := n1 + n2;
for i := 1 to n1 do
F1Book62.CopyRangeEx( i+n2,1,1,65536,256, F1Book61.SS,i,1,1,65536,256)
 
在DELPHI中的WMF在内存中是以EMF格式存放的,因此要改写文件的读入代码。
var
nX1: Single;
nY1: Single;
nX2: Single;
nY2: Single;
hMF:ole_HANDLE;
nMapMode: Integer;
nWndExtentX: Integer;
nWndExtentY: Integer;
memoryst:tmemorystream;
WMF: TMetafileHeader;
BitMem: Pointer;
length:integer;
begin
if openpicturedialog.Execute then
begin
nx1:=excelbook.SelStartcol;
ny1:=excelbook.SelStartrow;
nmapmode:=8;
memoryst:=tmemorystream.create;
memoryst.loadfromfile(openpicturedialog.FileName);
memoryst.position:=0;
memorySt.Read(WMF, SizeOf(WMF));
length:=memoryst.size;
Dec(Length, SizeOf(WMF));
GetMem(Bitmem, Length);
memoryst.Read(BitMem^, Length);
if WMF.Inch = 0 then WMF.Inch := 96;
nwndextentx:=MulDiv(WMF.Box.Right - WMF.Box.Left,2540,WMF.Inch);
nwndextenty:=MulDiv(WMF.Box.Bottom - WMF.Box.Top,2540,WMF.Inch);
nx2:=nx1+nwndextentx/1740
//我的单元格宽度 ,可修改
ny2:=ny1+nwndextenty/430
//我的单元格的高度
hmf:=SetMetaFileBitsEx(length,bitmem);
excelbook.ObjcreatePicture(nx1,ny1,nx2,ny2,hmf,nmapmode,nwndextentx,nwndextenty);
Freemem(BitMem, Length);
memoryst.free;
end;
end;
把上面的程序改一下肯定能读入*。WMF 格式的文件的
 
后退
顶部