FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oGraph- how to save into bmp in silent mode
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
oGraph- how to save into bmp in silent mode
Posted: Fri Aug 15, 2014 10:21 PM
To all,
I use xBrowse as a preview for a report.
Now I would like to print this report.
On each single line I would like to print the corresponding graph.

Does someone know how to convert oGraphs in silent mode to bmp.

Best regards,
Otto

Posts: 195
Joined: Sun Jul 22, 2012 07:01 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Sat Aug 16, 2014 12:17 AM

I assume you are using the TGraph() class. If so, it has a Save2Bmp() method, have you tried that? I haven't tried it but I don't see anything that make it to be not silent.

METHOD Save2Bmp( cFile ) CLASS TGraph

LOCAL hBmp, hDib
DEFAULT cFile := "TGraph.Bmp"

hBmp := WndBitmap( Self:hWnd )
hDib := DibFromBitmap( hBmp )
DibWrite( cFile, hDib )
GloBalFree( hDib )
DeleteObject( hBmp )

RETURN ( FILE( cFile ) )

Best regards,

Robb

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Sat Aug 16, 2014 06:25 PM
Hello Robb,
thank you for your help.
The method is working.
After a long time I am using again ER.
I have to re-learn the handling and find a workflow for me.
I have also to look into the paint method of oGraph to reduce the margin.
The margin around the graphs consume to much space.
Thanks again and best regards,
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Sat Aug 16, 2014 06:29 PM
This is the source code for calling the Report:

Code (fw): Select all Collapse
function printMonatsvgl()
   local oVRD
   local cBmp := ""
   local I := 0
   *----------------------------------------------------------

   EASYREPORT oVRD NAME ".\xVRD\EasyReportExample1.vrd" //;
   //   PREVIEW lPreview TO cPrinter   PRINTDIALOG IIF( lPreview, .F., .F. )

   IF oVRD:lDialogCancel = .T.
      RETURN( .F. )
   ENDIF

   select jahresvgl
   go top
   do while .not. eof()
      I:= I + 1
      PRINTAREA 2 OF oVRD
      cbmp := "BMP" + ALLTRIM(STR(I))+".bmp"

      if I > 12

         IF oVRD:nNextRow > oVRD:nPageBreak
            PAGEBREAK oVRD
            //        PRINTAREA 2 OF oVRD
         ENDIF

         PRINTAREA 4 OF oVRD;
            ITEMIDS    { 100,110,120,130,140,150,160,170 } ;
            ITEMVALUES {  jahresvgl->MONAT    ,;
            transform(jahresvgl->JAHR      , "@E 9999,999" ),;
            transform(jahresvgl->DIFF_J_1   , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS1 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS2 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS3 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS4 , "@E 9999,999" ), cbmp }

      else
         PRINTAREA 3 OF oVRD;
            ITEMIDS    { 100,110,120,130,140,150,160,170 } ;
            ITEMVALUES {  jahresvgl->MONAT    ,;
            transform(jahresvgl->JAHR      , "@E 9999,999" ),;
            transform(jahresvgl->DIFF_J_1   , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS1 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS2 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS3 , "@E 9999,999" ),;
            transform(jahresvgl->JAHRMINUS4 , "@E 9999,999" ), cbmp }

      endif

      skip
   enddo

   oVRD:End()

   select jahresvgl
   go top
return nil
//----------------------------------------------------------------------------//


Best regards,
Otto
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Sat Aug 16, 2014 06:56 PM
Hello,
please see how nice xBrowse and EasyReport are working.
Frist you see a report-live-preview. The user can add and delete subtotals wherever you need in your report.
Then you can print the report including the graphs.

Best regards,
Otto

VIDEO
http://www.atzwanger-software.com/fw/Jahrsvergleich.mp4
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Sat Aug 16, 2014 07:01 PM

Otto

In the spanish section of Easyreport forum they're making great progress and building an awesome product.

Saludos,



Eduardo
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Tue Feb 09, 2016 06:54 PM
Otto Good afternoon, thing is, I need to create graphics in silent mode and then print a report on EasyReport , by chance you have an example of how. I'm using the tgraph .

At this point I think a dialogue to show the image, but it only works when the dialog is closed.
This is the function .

Cheers

Code (fw): Select all Collapse
*********************************************
**esta funcion genera el bmp con los consumos
*********************************************
FUNCTION creabmp(vMan,vLot,vPer) 

LOCAL oGraph ,aCan:={} ,aDia:={}
Local vRuta:=alltrim(vMan)+"-"+alltrim(vLot)+"-"+alltrim(vPer)
DEFINE DIALOG oDlg SIZE 600, 500 
   
for n := 1 to 5
  AAdd(aDia,"mes"+Str(n))
  AAdd(aCan,n)
next    
    
@ 1, 1 GRAPH oGraph SIZE 250, 200 TYPE 1 XVALUES YVALUES 3D XGRID YGRID //LEGENDS 
    
  oGraph:cTitX   :="Consumo Manzana"+alltrim(vMan)+" - Lote:"+alltrim(vLot)
  oGraph:cTitY   :="Meses"
  oGraph:lPopUp  :=.F.
  oGraph:nClrX = CLR_GREEN 
  oGraph:nClrY = CLR_RED 
  oGraph:AddSerie(aCan,"",RGB(128,128,255))
   
ACTIVATE DIALOG oDlg CENTER VALID (oGraph:save2bmp("c:\cartera\pictures\"+vRuta+".bmp"),.T.)

RETURN NIL
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: oGraph- how to save into bmp in silent mode
Posted: Tue Feb 09, 2016 09:21 PM

Otto,

I am not sure exactly what you are trying to do, but if you need to draw the graph, then save it to a bitmap, then you probably can draw it on an invisible window or dialog, then save it and end the window or dialog.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion