_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx","vcx"))) > >LOCAL loListener as ReportListener >loListener = CREATEOBJECT("WatermarkListener") > >loListener.LISTENERTYPE = 1 >loListener.WaterMarkImage = HOME() + "Graphics\Gifs\morphfox.gif" >loListener.WaterMarkType = 1 && 1 = Colored ; 2 = GreyScale >loListener.WaterMarkTransparency = 0.25 && 0 = transparent ; 1 = Opaque >loListener.WaterMarkWidthRatio = 0.75 && 0 - 1 >loListener.WaterMarkHeightRatio = 0.75 && 0 - 1 >loListener.RenderType = 2 && 1 = Before rendering page ; 2 = After rendering page > >* Run the report using the new report engine (object-assisted output) >REPORT FORM (ADDBS(HOME()) + "samples/solution/europa/employeesmd.frx") OBJECT loListener > >RETURN > > > > > >DEFINE CLASS WatermarkListener AS _ReportListener OF HOME() + "FFC\" + "_ReportListener.VCX" > NewPage = .T. > WaterMarkImage = "" > WaterMarkType = 1 && 1 = Colored ; 2 = GreyScale > WaterMarkTransparency = 0.50 && 0 = transparent ; 1 = Opaque > WaterMarkWidthRatio = 0.50 > WaterMarkHeightRatio = 0.50 > RenderType = 1 && 1 = Before rendering page ; 2 = After rendering page > oGDIGraphics = NULL > oBmp = NULL > oImgAttrib = NULL > oRect = NULL > > FUNCTION BEFOREREPORT > DODEFAULT() > > WITH _SCREEN.SYSTEM.Drawing > > This.oGDIGraphics = .Graphics.New() > > LOCAL lnX, lnY, lnWidth, lnHeight > lnX = (1 - This.WaterMarkWidthRatio) / 2 > lnY = (1 - This.WaterMarkHeightRatio) / 2 > lnWidth = This.WaterMarkWidthRatio > lnHeight = This.WaterMarkHeightRatio > > * Create a Rectangle of the size of 60% of the report page > This.oRect = .Rectangle.New(lnX * This.sharedPageWidth, ; > lnY * This.sharedPageHeight, ; > This.sharedPageWidth * lnWidth, ; > This.sharedPageHeight * lnHeight) > > * Load the Image File to GDI+ > This.oBmp = .Bitmap.New(This.WaterMarkImage) > > * Create a color matrix > LOCAL loClrMatrix AS xfcColorMatrix > IF This.WaterMarkType = 2 && 1 = Colored ; 2 = GreyScale > loClrMatrix = .Imaging.ColorMatrix.New( ; > .33, .33, .33, 0 , 0, ; > .33, .33, .33, 0 , 0, ; > .33, .33, .33, 0 , 0, ; > 0, 0, 0, This.WaterMarkTransparency, 0, ; > 0, 0, 0, 0, 0) > ELSE > loClrMatrix = .Imaging.ColorMatrix.New() > loClrMatrix.Matrix33 = This.WaterMarkTransparency > ENDIF > > * Create an ImageAttributes and associate the ClrMatrix to it > This.oImgAttrib = .Imaging.ImageAttributes.New() > This.oImgAttrib.SetColorMatrix(loClrMatrix) > > ENDWITH > ENDFUNC > > FUNCTION BEFOREBAND(nBandObjCode, nFRXRecNo) > #DEFINE FRX_OBJCOD_PAGEHEADER 1 > IF nBandObjCode==FRX_OBJCOD_PAGEHEADER AND This.RenderType = 1 && Before the page is rendered > This.DrawWatermark() > ENDIF > DODEFAULT(nBandObjCode, nFRXRecNo) > ENDFUNC > > PROCEDURE AfterBand(nBandObjCode, nFRXRecNo) > #DEFINE FRX_OBJCOD_PAGEFOOTER 7 > IF nBandObjCode==FRX_OBJCOD_PAGEFOOTER AND This.RenderType = 2 && After the page is rendered > This.DrawWatermark() > ENDIF > DODEFAULT(nBandObjCode, nFRXRecNo) > ENDPROC > > PROCEDURE DrawWatermark > IF NOT EMPTY(This.WatermarkImage) > > * Get GDI+ Graphics handle > IF NOT This.IsSuccessor > This.SharedGDIPlusGraphics = This.GDIPLUSGRAPHICS > ENDIF > This.oGDIGraphics.Handle = This.SharedGDIPlusGraphics > > * Draw the watermark > This.oGdiGraphics.DrawImage(This.oBmp, This.oRect, This.oBmp.GetBounds(), 2, This.oImgAttrib) > ENDIF > ENDPROC > >ENDDEFINE