如何在PB中调用F1控件如何插入图片(原创)

类别:数据库 点击:0 评论:0 推荐:

一、API声明:

SUBROUTINE  CopyMemory(ref METAHEADER Destination , ref blob Source, long Length)  LIBRARY "kernel32"  Alias for "RtlMoveMemory"
SUBROUTINE  CopyMemory2(ref blob Destination , ref blob Source, long Length)  LIBRARY "kernel32"  Alias for "RtlMoveMemory"
Function ulong SetMetaFileBitsEx(ulong nSize,ref blob lpData) LIBRARY "gdi32.dll"

二、PB脚本:

METAHEADER lst_Hdr
integer li_FileNum
Long ll_hMF,ll_loops,ll_pos,ll_len
blob lb_structure,lb_data,lb_tmp,lb_read

li_FileNum = FileOpen("c:\1.wmf", StreamMode!)

FileSeek(li_FileNum, 22, FromBeginning!)

FileRead(li_FileNum, lb_structure)

CopyMemory(lst_Hdr,lb_structure,18)

lst_Hdr.mtSize = lst_Hdr.mtSize * 2

FileSeek(li_FileNum, 22, FromBeginning!)

IF lst_Hdr.mtSize > 32765 THEN
 IF Mod(lst_Hdr.mtSize, 32765) = 0 THEN
  ll_loops = lst_Hdr.mtSize/32765
 ELSE
  ll_loops = (lst_Hdr.mtSize/32765) + 1
 END IF
ELSE
 ll_loops = 1
END IF

FOR ll_pos = 1 to ll_loops
 FileRead(li_FileNum, lb_tmp)
 lb_read = lb_read + lb_tmp
NEXT

FileClose(li_FileNum)

if len(lb_read) < lst_Hdr.mtSize then
 ll_len = len(lb_read)
else
 ll_len = lst_Hdr.mtSize 
end if

lb_data = blob(space(ll_len))

CopyMemory2(lb_data,lb_read,ll_len)

ll_hMF = SetMetaFileBitsEx(lst_Hdr.mtSize, lb_data)

ole_1.object.ObjCreatePicture(1, 1, 3, 6, ll_hMF, 7, 0, 0)

三、使用API在PB中直接读取WMF的方式源码,参考:

http://www.comesoft.net/bbs/dispbbs.asp?boardid=78&id=26663

效果图见:

http://www.comesoft.net/bbs/UploadFile/2004-12/20041229151230298.JPG

http://blog.csdn.net/images/blog_csdn_net/balloonman2002/17312/o_DEMO.GIF

原贴见:http://community.csdn.net/Expert/topic/3673/3673523.xml?temp=.7985193

本文地址:http://com.8s8s.com/it/it19598.htm