Page 1 of 1

GRAPHPRN

PostPosted: Fri Oct 28, 2022 1:00 am
by Marco Augusto
Saludos

haciendo pruebas con la nueva funcionalidad de impresión directa de graficas

compilo el programa graphprn.prg

si utilizo el tipo de grafica PIE me manda error

Code: Select all  Expand view
function Main()

   local oGraph, oPrn, aTable, cRegion

   CreateDBF()

   USE GRAFDATA NEW VIA "DBFCDX"
   SET ORDER TO TAG MAIN
   GO TOP

   DEFINE GRAPH oGraph SIZE 250, 200 TYPE GRAPH_TYPE_PIE ;
      YVALUES XGRID YGRID XVALUES LEGENDS

   WITH OBJECT oGraph
      :aSeries = { { "DeskTop", METRO_AMBER  }, ;
                   { "Lap-Top", METRO_OLIVE  }, ;
                   { "Printer", CLR_HMAGENTA } }
      :aYVals = { "Jan", "Feb", "Mar", "Apr", "May" }
      :lViewSRLegend = .T.
      :cTitle := "ABC COMPANY"
   END

   PRINT oPrn PREVIEW

   for each cRegion in { "NORTH", "SOUTH" }

      oGraph:aData   := FW_DbfToArray( "JAN,FEB,MAR,APR,MAY", { || FIELD->REGION = cRegion } )
      oGraph:cTitle  := "ABC COMPANY, " + cRegion + " REGION"

      PAGE

      @ 1, 1   PRINT TO oPrn GRAPH oGraph SIZE 5,4 INCHES
      @ 5, 1   PRINT TO oPrn TABLE oGraph:aTable SIZE 5, 2 INCHES
      @ 7, 1.5 PRINT TO oPrn CHART oGraph:aTable SIZE 4, 3 INCHES

      ENDPAGE

   next

   ENDPRINT

   oGraph:End()
   CLOSE DATA

return nil

//----------------------------------------------------------------------------//

static function CreateDBF()

   field REGION, PRODUCT

   local aData := ;
   {  { "NORTH", "DeskTop", 14280, 20420, 12870, 25347,  7640 } ;
   ,  { "NORTH", "Lap-Top",  8350, 10315, 15870,  5347, 12340 } ;
   ,  { "NORTH", "Printer", 12345,  8945, 10560, 15600, 17610 } ;
   ,  { "SOUTH", "DeskTop", 12345,  8945, 10560, 15600, 17610 } ;
   ,  { "SOUTH", "Lap-Top", 14280, 20420, 12870, 25347,  7640 } ;
   ,  { "SOUTH", "Printer",  8350, 10315, 15870,  5347, 12340 } ;
   }

   DBCREATE( "GRAFDATA", { { "REGION", "C", 5, 0 }, { "PRODUCT", "C", 7, 0 }, ;
      { "JAN", "N", 5, 0 }, { "FEB", "N", 5, 0 }, { "MAR", "N", 5, 0 }, ;
      { "APR", "N", 5, 0 }, { "MAY", "N", 5, 0 } }, "DBFCDX", .T., "DATA" )

  FW_ArrayToDBF( aData )

  GO TOP
  INDEX ON REGION+PRODUCT TAG MAIN
  CLOSE DATA

return nil

//----------------------------------------------------------------------------//
 


Error description: Error BASE/1004 Class: 'NIL' has no exported method: GETDC
Args:
[ 1] = U

Stack Calls
===========
Called from: => GETDC( 0 )
Called from: .\source\classes\TGRAPH.PRG => TGRAPH:DRAWPIE( 2194 )
Called from: .\source\classes\TGRAPH.PRG => TGRAPH:PAINT( 970 )
Called from: .\source\classes\TGRAPH.PRG => TGRAPH:PRINT( 2355 )
Called from: .\source\classes\PRINTER.PRG => TPRINTER:PRINTGRAPH( 1286 )
Called from: GP3.prg => MAIN( 44 )

Re: GRAPHPRN

PostPosted: Tue Nov 08, 2022 4:45 am
by nageswaragunupudi
We are sorry. There is a bug in TGraph.prg while printing PIE chart directly to printer. Painting on screen works well.

We suggest the fix here. You may apply this fix to tgraph.prg.

Line 2194 in the Method DrawPie() of TGraph.prg:
Existing code:
Code: Select all  Expand view
hMemCDC := ::oWnd:GetDC()


Substitute with this revised code:
Code: Select all  Expand view
hMemCDC := If( ::oWnd == nil, GetDC( 0 ), ::oWnd:GetDC() )


Next, go to line 2198.
Existing code:
Code: Select all  Expand view
::oWnd:ReleaseDC()


Substitute with this revised code:
Code: Select all  Expand view
if ::oWnd == nil; ReleaseDC( 0, hMemCDC ); else; ::oWnd:ReleaseDC(); endif


With this change your program works.
We would be glad if you apply the fix and confirm its working.

Re: GRAPHPRN

PostPosted: Tue Nov 08, 2022 8:38 pm
by Marco Augusto
gracias
sí funcionó!

Re: GRAPHPRN

PostPosted: Wed Nov 09, 2022 12:00 am
by nageswaragunupudi
Thanks for your confirmation.
This fix is included for the next release.