Freigeben über


GDIPlusGraphics Property

Provides access to the GDIPlus Graphics object the ReportListener uses to handle output.

ReportListener.GDIPlusGraphics

Return Value

Integer data type.

The default is 0. This property is readonly.

Remarks

Applies To: ReportListener Object.

This property gives derived ReportListener-based classes a way to inject their own output into the output stream, by accessing the baseclass ReportListener's handle to this stream.

Important

When code written in Visual FoxPro accesses this handle, it must DECLARE and use functions based in the same file copy of GDIPLUS.DLL that the product uses in native code. To ensure this, use the syntax IN GDIPLUS.DLL with no explicit path in your DECLARE DLL statements.

Visual FoxPro ships with a number of Foundation Classes designed to make working with the GDI+ API easier to use. For more information, see GDI Plus API Wrapper Foundation Classes.

Example

This example adjusts all text in the Page Header band of a report by rotating it to an angle, similar to an angled set of headers in a spreadsheet. Such an approach is useful when you have a report with many columns and the labels for each column header would ordinarily take up much more room than the contents of each column requires in the Detail band.

LOCAL oListener
oListener = CREATEOBJECT("rotateText")
oListener.ListenerType = 1
REPORT FORM ? OBJECT oListener

#define FRX_OBJCOD_PAGEHEADER 1 

DEFINE CLASS rotateText AS ReportListener

   IsInPageHeader = .F. 

   PROCEDURE Init() 
      DECLARE integer GdipRotateWorldTransform In GDIPlus.Dll ;
            integer graphics,single angle,integer enumMatrixOrder_order
      DECLARE integer GdipTranslateWorldTransform In GDIPlus.Dll ;
            integer graphics,single dx,single dy,;
            integer enumMatrixOrder_order
      DECLARE integer GdipSaveGraphics IN GDIPlus.DLL ;
          integer graphics, integer @xx
      DECLARE integer GdipRestoreGraphics IN GDIPlus.DLL ;
          integer graphics, integer xx
   ENDPROC 

   PROCEDURE BeforeBand(nBandObjCode, nFRXRecNo) 
      DODEFAULT(nBandObjCode, nFRXRecNo) 
      IF (nBandObjCode = FRX_OBJCOD_PAGEHEADER) 
         THIS.IsInPageHeader = .T.
      ENDIF 
   ENDPROC

   PROCEDURE AfterBand(nBandObjCode, nFRXRecNo)
      IF (nBandObjCode = FRX_OBJCOD_PAGEHEADER)
         THIS.IsInPageHeader = .F.
      ENDIF 
      DODEFAULT(nBandObjCode, nFRXRecNo)
   ENDPROC

   PROCEDURE Render(nFRXRecNo, nLeft, nTop, nWidth, nHeight,;
       nObjectContinuationType, cContentsToBeRendered, GDIPlusImage) 
      LOCAL xx,x,y, z
      xx = 0
      IF THIS.IsInPageHeader
         * get appropriate versions of coords
         x = nLeft
         y = nTop

         * save the current state of the graphics handle
         z = GdipSaveGraphics(this.GDIPlusGraphics, @xx)

         * now move the 0,0 point to where we'd like it to be
         * so that when we rotate we're rotating around the
         * appropriate point 
         z = GdipTranslateWorldTransform(this.GDIPlusGraphics,x,y,0)
         * should check z here -- will be 0 if no error occurred

         * now change the angle at which the draw will occur
         z = GdipRotateWorldTransform ( this.GDIPlusGraphics,-20,0)
         * should check z as above

         * restore the 0,0 point
         z = GdipTranslateWorldTransform(this.GDIPlusGraphics,-x,-y, 0)
         * should check z as above   

      ENDIF

      * explicitly call the baseclass behavior 
      * when we are ready for it
      DODEFAULT(nFRXRecNo, nLeft, nTop, nWidth, nHeight, ;
               nObjectContinuationType, cContentsToBeRendered, ;
               GDIPlusImage)

      * put back the state of the graphics handle 
      IF THIS.IsInPageHeader
         GdipRestoreGraphics(this.GDIPlusGraphics, xx)
      ENDIF

      * don't let the baseclass render 
      * when and how it would otherwise do it 
      NODEFAULT 

   ENDPROC

ENDDEFINE 

See Also

Reference

DECLARE - DLL Command

Other Resources

Properties (Visual FoxPro)
Language Reference (Visual FoxPro)
Extending Report Output Functionality