Hardcopy problem

Hardcopy problem

Postby Detlef Hoefner » Thu May 07, 2009 8:07 pm

Does oDlg:HardCopy( nZoom, lUser ) still work with FWH 9.03?

I have a dialog where i paint a diagram with fillrect() and textout() commands.
I put a button on it to print this diagram.
But the printer just ejects an empty page.

Image

Here my code. Perhaps someone solved the same problem?.

Thanks and regards,
Detlef
Code: Select all  Expand view
//////////////////////////
PROCEDURE Diagramm( oWnd )
//////////////////////////
LOCAL aLabel   := aLast13Month( date(), .t. )
LOCAL aVal     := array( 13 )
LOCAL cTitle   := OemToAnsi( alltrim( tmp->artnr ) + " has been sold   " + XTRIM( tmp->vk_total ) + " times" )
LOCAL nMonth   := tmp->( fieldpos( "VK00M" ) )
LOCAL oDlg, oFnt, n


   for n := 1 to 13
      aVal [ n ] := tmp->( fieldget( n - 1 + nMonth ) )
   next

   aVal := aRevertArr( aVal )

   DEFINE FONT  oFnt NAME "Ms Sans Serif" SIZE 0, -8
   DEFINE DIALOG oDlg NAME "GraphWin" ;
          TITLE cTitle;
          COLOR GetSysColor( COLOR_BTNTEXT ),;
                GetSysColor( COLOR_BTNFACE ) FONT oFnt of oWnd

   REDEFINE BUTTON ID 10  OF oDlg ACTION oDlg:End()
   REDEFINE BUTTON ID 20  OF oDlg ACTION oDlg:hardcopy( 1 )


   ACTIVATE DIALOG oDlg CENTERED ON PAINT GraphWnd( aVal, aLabel, .f. )
   RELEASE FONT oFnt
RETURN

///////////////////////////////////////////
FUNCTION GraphWnd( aVal, aLabel, lNegativ )
///////////////////////////////////////////
LOCAL aRect, hWnd, hDC, oBrush, n, nVal
LOCAL nYDim, nXDim, nYStart, nXStart, nYEnd, nXEnd, nXStep, nYStep, nYMax


   DEFAULT lNegativ := .t.
   DEFAULT aVal     := {  30,    25,    42,    75,    37,    2,     68,    54,    46,    27,    61,    112 }
   DEFAULT aLabel   := { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" }


      hWnd  := GetActiveWindow()
      hDC   := GetDC( hWnd )

      // get coordinates of actual window
      // --------------------------------
      aRect := GetClientRect( hWnd )

      // making the drawing-window a bit smaller
      // ---------------------------------------
      nYStart := aRect[ 1 ] + 10
      nXStart := aRect[ 2 ] + 50
      nYEnd   := aRect[ 3 ] - 80
      nXEnd   := aRect[ 4 ] - 10

      // valid X- and Y-Dimensions
      // -------------------------
      nYDim   := nYEnd - nYStart + 1
      nXDim   := nXEnd - nXStart + 1

      // searching maximum Y-Value
      // -------------------------
      nYMax := 0
      for n := 1 to len( aVal )
          nYMax := max( nYMax, aVal[n] )
      next

      // Scaling Factors for X and Y-Axes
      // --------------------------------
      nXStep := nXDim / ( len( aVal ) * 2 )

      nYStep := ( nYDim - 20 ) / nYMax
                      //   |  this is only for NOT hitting exactly
                      //   +- the top of the output-window


      // drawing the output-window
      // -------------------------
      WndBoxRaised( hDC, nYStart - 2, nXStart, nYEnd + 2, nXEnd )

      SetTextColor( hDC, CLR_BLACK )
      SetBkColor  ( hDC, GetSysColor( COLOR_BTNFACE ) )

      DEFINE BRUSH oBrush COLOR CLR_R_YELLOW

      // drawing the bars for all values
      // -------------------------------
      for n := 1 to len( aVal )
         nVal := aVal[ n ]

         FillRect( hDC, { if ( !lNegativ .and. nVal < 0, nYEnd   + 1, nYEnd   + 1 - ( nVal * nYStep ) ),;  // top-Y-Value
                          nXStart + ( ( n - 1 ) * nXStep * 2 ) + ( ( nXStep - 1 ) / 2 ),;
                          nYEnd   + 1,;                           // bottom-Y-Value
                          nXStart + ( ( n - 1 ) * nXStep * 2 ) + ( ( nXStep - 1 ) / 2 )+ nXStep;
                        },;
                   oBrush:hBrush )

         // drawing numeric Y-values to the bars
         // ------------------------------------
         TextOut( hDC,;
                  if ( !lNegativ .and. nVal < 0, nYEnd + 1 - 20, nYEnd + 1 - ( aVal[ n ] * nYStep ) - 20 ),;
                  nXStart + ( ( n - 1 ) * nXStep * 2 ) + ( ( nXStep - 1 ) / 2 ) - 2,;
                  padl( XTRIM( aVal[ n ] ), 3 ) )

         // drawing the labels for X-Axes
         // -----------------------------
         TextOut( hDC, nYEnd + 4,;
                       nXStart + ( ( n - 1 ) * nXStep * 2 ) + ( ( nXStep - 1 ) / 2 ) - 2,;
                       aLabel[ n ] )
      next

      // show Label with years at bottom line
      // ------------------------------------
      TextOut( hDC, nYEnd + 25, nXStart + ( ( nXStep - 1 ) / 2 ) - 2 , str( year( date() ) - 1, 4, 0 ) )
      TextOut( hDC, nYEnd + 25, nXEnd - 35, str( year( date() ),   4, 0 ) )

      RELEASE BRUSH oBrush
      ReleaseDc( hWnd, hDC )

RETURN NIL

///////////////////////////////////////
FUNCTION aLast13Month( dStart, lLabel )
///////////////////////////////////////
LOCAL nMonth := month( dStart )
LOCAL nYear  := year( dStart )
LOCAL n      := 0
LOCAL aRet   := {}
LOCAL aMonth := { "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" }
LOCAL cBuf   := ""


   DEFAULT lLabel := .f.


   cBuf := cYearMonth( dStart )

   aadd( aRet, if( lLabel, aMonth[ val( right( cBuf, 2 ) ) ], cBuf ) )

   for n := 1 to 12
      if ( --nMonth < 1 )
         --nYear
         nMonth := 12
      endif

      cBuf := cYearMonth( ctod( "01." + strzero( nMonth, 2, 0 ) + "." + strzero( nYear, 4, 0 ) ) )
      aadd( aRet, if( lLabel, aMonth[ val( right(cBuf, 2 ) ) ], cBuf ) )
   next

   if lLabel
      aRet := aRevertArr( aRet )
   endif
RETURN( aRet )
 
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby James Bott » Fri May 08, 2009 12:46 am

Detlef,

I remember this problem being reported before. If I remember correctly it was the printer driver. Can you try it using a different printer?

You might search the forum for other messages on this topic.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Hardcopy problem

Postby Detlef Hoefner » Fri May 08, 2009 6:34 am

Jasmes,

thanks for your hints.
In the forum search i only found scaling parameter issues and nothing about empty pages.

I tried HP Laser printer and Adobe PDF printer.
Both produce empty papers.

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby Antonio Linares » Fri May 08, 2009 6:36 am

Detlef,

Please try

oDlg:SaveToBmp( cBmpFile )

and check if you get the right bitmap file, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Hardcopy problem

Postby Detlef Hoefner » Fri May 08, 2009 7:02 am

Antonio Linares wrote:Detlef,

Please try

oDlg:SaveToBmp( cBmpFile )

and check if you get the right bitmap file, thanks

Antonio,

yes, the bmp file is correctly created.
So it's really a printer driver problem?

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby Antonio Linares » Fri May 08, 2009 9:44 am

Detlef,

Please try this code, and check if you see the bitmap in the preview, thanks:
Code: Select all  Expand view

PRINTER oPrn PREVIEW
   PAGE
      WndPrint( oDlg:hWnd, oPrn:hDC, 10, 10, 1 )
   ENDPAGE
ENDPRINT
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41406
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Hardcopy problem

Postby Detlef Hoefner » Fri May 08, 2009 10:12 am

Antonio,

the previews comes up with an empty page :(

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby Detlef Hoefner » Mon May 11, 2009 11:56 am

Antonio,

do you have any new idea about my hardcopy problem?

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby James Bott » Mon May 11, 2009 1:29 pm

Detlef,

Have you tried it with just a plain empty dialog? Do you get the same result?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Hardcopy problem

Postby Detlef Hoefner » Mon May 11, 2009 3:26 pm

James,

it doesn't work even with a plain empty dialog.
You might try with the following code to succeed.
I get an empty paper.
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg


   DEFINE DIALOG oDlg TITLE "I am a DialogBox"


   @ 3,  5 BUTTON "&Print" SIZE 40, 12 ACTION oDlg:HardCopy( 1 )
   @ 3, 16 BUTTON "&Close" SIZE 40, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED
RETURN nil

 

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby Otto » Mon May 11, 2009 9:09 pm

Hello Detlef,

I use these functions to print a graph inside a report - I use EasyReport.
Best regards,
Otto





Code: Select all  Expand view
function graph(oReport,aBeschriftung,aReihe1)
   local oDlg, oGraph


   DEFINE DIALOG oDlg;
      SIZE 600, 500

   @ 1, 1 GRAPH oGraph;
      SIZE 250, 200;
      TYPE 1;
      YVALUES 3D XGRID YGRID XVALUES LEGENDS

   oGraph:aSeries = { { "Nächtigungen", CLR_YELLOW ,1,.T. }}

   oGraph:aYVals = aBeschriftung
   aadd(oGraph:aData,aReihe1 )


   oGraph:nClrX = CLR_GREEN
   oGraph:nClrY = CLR_RED

   @ 0, 0 BUTTON "Druck" ACTION ( graphprint(oGraph,oReport),oDlg:End() )

   ACTIVATE DIALOG oDlg  CENTER


return nil


function graphprint (oGraph,oReport)
   local oPrn, nTop := 3.0, nLeft := 2.0, nHeight := 9, nWidth := 16

   oPrn:=PrintBegin("Aufloesung",.F.,.T.,,.T.)

   oPrn:SetPortrait()
   oPrn:Cmtr2Pix(@nTop , @nLeft)
   oPrn:Cmtr2Pix(@nWidth, @nHeight)

   sysRefresh()
   oPrn:End()


   nTop   :=  INT(nTop)
   nLeft  := INT(nLeft)
   nWidth := INT(nWidth)
   nHeight:= INT(nHeight)

   oGraph:Print( oReport:oDevice,nTop,nLeft,nWidth,nHeight )

return NIL
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6068
Joined: Fri Oct 07, 2005 7:07 pm

Re: Hardcopy problem

Postby Detlef Hoefner » Mon May 11, 2009 9:43 pm

Hallo Otto,

many thanks for your help and coding example.
But i just wanted to know if the call of oDlg:Hardcopy() should work with FWH 9.03 or not.
Even the sample of Fivewin don't print the dialog.

I'm not sure if it's a printer driver issue as James supposes or a nasty bug of the class TWindow.
And so i still wait for an answer of Antonio.

Thanks and regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Re: Hardcopy problem

Postby nageswaragunupudi » Tue May 12, 2009 4:11 am

oDlg:HardCopy() is Working for me with FWH 9.04.
In the above code posted by Mr Antonio, preview is not working. But PRINTER oPrn ( without preview ) is working.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Hardcopy problem

Postby Detlef Hoefner » Thu May 14, 2009 7:48 am

Antonio,

do you have any new idea about my hardcopy problem?

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 34 guests