TPrinter:CmSay() and PrnOffset()

TPrinter:CmSay() and PrnOffset()

Postby Ken Wantz » Fri Oct 03, 2008 3:52 pm

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  Expand view
   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?
Ken Wantz
 
Posts: 45
Joined: Wed Nov 29, 2006 7:48 pm
Location: Toronto Canada

Postby Antonio Linares » Fri Oct 03, 2008 10:53 pm

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  Expand view
   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  Expand view
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 }
regards, saludos

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

Postby Antonio Linares » Fri Oct 03, 2008 11:00 pm

Ken,

> PrnOffset()

Lets modify source\winapi\printdc.c this way:
Code: Select all  Expand view
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 :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests