以下是引用wangzhiyi在2016-10-14 08:28:00的发言:
老大,能教教如何在一个报表文件里同时实现字段域与GDI+处理的图片吗?
显示图片示例:
程序代码:
**
** test.prg
**
DECLARE LONG GdipLoadImageFromFile IN GDIPlus.DLL STRING@, LONG@
DECLARE LONG GdipDisposeImage IN GDIPlus.DLL LONG
DECLARE LONG GdipDrawImageRect IN GDIPlus.DLL LONG, LONG, SINGLE, SINGLE, SINGLE, SINGLE
CREATE CURSOR tt (Name C(10), FileName C(240))
INSERT INTO tt VALUES ("张三", "C:\TEMP\Test\分班\36042919821017001X.jpg")
INSERT INTO tt VALUES ("李四", "C:\TEMP\Test\分班\320321199202204233.jpg")
oRL = CREATEOBJECT("myReportListener")
oRL.ListenerType = 1
REPORT FORM 报表扩展功能示例(图片).frx OBJECT oRL
CLEAR DLLS
RETURN
DEFINE CLASS myReportListener AS ReportListener
DynamicLineHeight = .F.
IsRotate = .F.
PROCEDURE BeforeBand(nBandObjCode, nFRXRecNo)
DODEFAULT(nBandObjCode, nFRXRecNo)
this.IsRotate = (nBandObjCode==4)
ENDPROC
PROCEDURE AfterBand(nBandObjCode, nFRXRecNo)
this.IsRotate = .F.
DODEFAULT(nBandObjCode, nFRXRecNo)
ENDPROC
PROCEDURE Render(nFRXRecNo, nLeft, nTop, nWidth, nHeight,;
nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
IF this.IsRotate AND (STRCONV(cContentsToBeRendered,6)==ALLTRIM(tt.FileName))
LOCAL hImage
hImage = 0
GdipLoadImageFromFile(STRCONV(ALLTRIM(tt.FileName)+0h00,5), @hImage)
GdipDrawImageRect(this.GDIPlusGraphics, hImage, nLeft, nTop, nWidth, nHeight)
GdipDisposeImage(hImage)
NODEFAULT
ELSE
DODEFAULT(nFRXRecNo, nLeft, nTop, nWidth, nHeight, ;
nObjectContinuationType, cContentsToBeRendered, GDIPlusImage)
ENDIF
ENDPROC
ENDDEFINE