FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Is it possible to specify background color of printed text?
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Is it possible to specify background color of printed text?
Posted: Fri Sep 26, 2014 08:42 AM

Using TPrinter, is it possible to specify the background color of the text to be printed? If not, is there any alternatives?

TIA

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Is it possible to specify background color of printed text?
Posted: Fri Sep 26, 2014 12:59 PM
Try using:

Code (fw): Select all Collapse
SETBKCOLOR( oPrn:hDCOut, nClr )


EMG
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Is it possible to specify background color of printed text?
Posted: Fri Sep 26, 2014 05:57 PM

Thanks for the reply Enrico.

Already tried that. Didn't work.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Is it possible to specify background color of printed text?
Posted: Fri Sep 26, 2014 06:02 PM
This is a working sample:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oPrn

    PRINT oPrn PREVIEW
        PAGE
            SETBKCOLOR( oPrn:hDCOut, CLR_HRED )
            oPrn:Say( 0, 0, "This is a test", , , CLR_WHITE, 2 )
        ENDPAGE
    ENDPRINT

    RETURN NIL


EMG
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Is it possible to specify background color of printed text?
Posted: Mon Sep 29, 2014 01:58 AM
Enrico,

Your sample works but when I tried inserting SetBkCOlor() in fwh\samples\testprn2.prg as below, the background color doesn't change

Code (fw): Select all Collapse
// Sample showing how to manage the printer object

#include "FiveWin.ch"

static oWnd

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

function Main()

   local oPrn, oFont
   local nRowStep, nColStep
   local nRow := 0, nCol := 0, n, m

   // PrnSetSize( 2100, 1200 )     To adjust a different printer paper size!

   PRINT oPrn NAME "Testing the printer object from FiveWin" PREVIEW

      if Empty( oPrn:hDC )
         return nil          // Printer was not installed or ready
      endif

      DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn

      nRowStep = oPrn:nVertRes() / 20   // We want 20 rows
      nColStep = oPrn:nHorzRes() / 15   // We want 15 cols

      PAGE
         oPrn:SayBitmap( 1, 1, "..\bitmaps\fivewin.bmp" )
         for n = 1 to 20  // rows
             nCol = 0
             SETBKCOLOR( oPrn:hDCOut, CLR_HRED )
             oPrn:Say( nRow, nCol, Str( n, 2 ), oFont )
             nCol += nColStep
             for m = 1 to 15
                oPrn:Say( nRow, nCol, "+", oFont )
                nCol += nColStep
             next
             nRow += nRowStep
         next
         oPrn:Line( 0, 0, nRow, nCol )
      ENDPAGE

      PAGE
         nRow = 0
         oPrn:SayBitmap( 1, 1, "..\bitmaps\fivewin.bmp" )
         for n = 1 to 20  // rows
             nCol = 0
             SETBKCOLOR( oPrn:hDCOut, CLR_HBLUE )
             oPrn:Say( nRow, nCol, Str( n + 20, 2 ), oFont )
             nCol += nColStep
             for m = 1 to 15
                oPrn:Say( nRow, nCol, "+", oFont )
                nCol += nColStep
             next
             nRow += nRowStep
         next
         oPrn:Line( 0, 0, nRow, nCol )
      ENDPAGE

   ENDPRINT

   oFont:End()      // Destroy the font object

return nil

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

procedure AppSys  // XBase++ requirement

return

//----------------------------------------------------------------------------//
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Is it possible to specify background color of printed text?
Posted: Mon Sep 29, 2014 08:28 AM
Code (fw): Select all Collapse
oPrn:Say( nRow, nCol, Str( n, 2 ), oFont, , , 2 )


EMG
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Is it possible to specify background color of printed text?
Posted: Tue Sep 30, 2014 01:54 AM

That did it. Thanks Enrico :D

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion