Page 1 of 1

TPrinter:CmSay() and PrnOffset()

Posted: Fri Oct 03, 2008 3:52 pm
by Ken Wantz
TPrinter:CmSay()

I allow a user to enter various text information at specific printer coordinates and found it easier if the coordinates where entered as millimeters. However, using oPrn:cmsay(), the input must be in centimeters which then gets converted back to millimeters.

Was there a reason why centimeters was chosen as opposed to millimeters?


PrnOffset()

Code: Select all

   Escape( ( HDC ) _parnl( 1 ),
           GETPRINTINGOFFSET,
           NULL, NULL, ( LPPOINT ) &pt ) ;
After looking at this function, I went to the MSDN site and found the following information:
Article ID : 115762
Last Review : November 21, 2006
Revision : 3.2

This article was previously published under Q115762

The Win32 documentation for the Escape() function says that the GETPHYSPAGESIZE, GETPRINTINGOFFSET, and GETSCALINGFACTOR escapes are obsolete, but it fails to mention the recommended way to get this information.

The information retrieved by all three escapes can now be retrieved by calling GetDeviceCaps() with the appropriate index:

• For the GETPHYSPAGESIZE escape, the indexes to be used with GetDeviceCaps() are PHYSICALWIDTH and PHYSICALHEIGHT.
• For GETPRINTINGOFFSET, the indexes are PHYSICALOFFSETX and PHYSICALOFFSETY.
• For GETSCALINGFACTOR, the indexes are SCALINGFACTORX and SCALINGFACTORY.
All six new indexes are defined in the file WINGDI.H, though they are missing from the GetDeviceCaps() documentation.
I am currently using FiveWin 7.04 so the code may have already been changed. If not, is there a reason why this existing code should not be updated?

Posted: Fri Oct 03, 2008 10:53 pm
by Antonio Linares
Ken,

> Was there a reason why centimeters was chosen as opposed to millimeters?

No, not a specific reason. Lets implement MmSay() too:

Code: Select all

   METHOD MmSay( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad );
       INLINE ;
       (::Mmtr2Pix(@nRow, @nCol),;
        ::Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ))

Code: Select all

METHOD Mmtr2Pix( nRow, nCol ) CLASS TPrinter

   if ValType( ::nYoffset ) == "U"
      ::nYoffset := 0
   endif
   if ValType( ::nXOffset ) == "U"
      ::nXoffset := 0
   endif

   nRow := Max( 0, ( nRow * ::nVertRes() / ::nVertSize() ) - ::nYoffset )
   nCol := Max( 0, ( nCol * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset )

return { nRow, nCol }

Posted: Fri Oct 03, 2008 11:00 pm
by Antonio Linares
Ken,

> PrnOffset()

Lets modify source\winapi\printdc.c this way:

Code: Select all

CLIPPER PRNOFFSET( PARAMS ) // ( hDC )  --> aPoint
{
   POINT pt;

   pt.y = 0;
   pt.x = 0;

   /*
   Escape( ( HDC ) _parnl( 1 ),
           GETPRINTINGOFFSET,
           NULL, NULL, ( LPPOINT ) &pt ) ;
   */
   
   pt.y = GetDeviceCaps( ( HDC ) _parnl( 1 ), PHYSICALOFFSETY	);       
   pt.x = GetDeviceCaps( ( HDC ) _parnl( 1 ), PHYSICALOFFSETX	);       

   _reta( 2 );

   #ifdef __FLAT__
      #ifndef __HARBOUR__
         #define _storni( x, y, z ) STORNI( x, params, y, z )
      #endif
   #endif

   _storni( pt.y, -1, 2 );
   _storni( pt.x, -1, 1 );
}
Many thanks for your information :-)