Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine printer top margin programmatically
Message
 
 
À
18/04/2006 23:59:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01114464
Message ID:
01114588
Vues:
20
>How do you determine programatically the top margin with which a report will be printed in a laser printer? I believe this is the margin that shows up in the Page Setup dialog of Word.

Hi Alex,

You can use GetDeviceCaps to retrieve a printer-specific information. The sample code below should get you started. See MSDN for details.
CLEAR 

#define LOGPIXELSX    88    && Logical pixels/inch in X         
#define LOGPIXELSY    90    && Logical pixels/inch in Y         

#define PHYSICALWIDTH   110 && Physical Width in device units   
#define PHYSICALHEIGHT  111 && Physical Height in device units  
#define PHYSICALOFFSETX 112 && Physical Printable Area x margin 
#define PHYSICALOFFSETY 113 && Physical Printable Area y margin 

DECLARE INTEGER GetDeviceCaps IN gdi32 ;
    INTEGER hDC,;
    INTEGER nIndex
    
DECLARE INTEGER CreateDC IN gdi32 ;
    STRING lpszDriver, ;
    STRING lpszDevice, ;
    INTEGER lpszOutput, ;
    INTEGER lpInitData

DECLARE INTEGER DeleteDC IN gdi32 ;
    INTEGER hDC

    
lcPrinter = SET("Printer",3)
lnDC = CreateDC("", lcPrinter, 0, 0)

lnPixelsPerInchY = GetDeviceCaps(lnDC, LOGPIXELSY)
lnPixelsPerInchX = GetDeviceCaps(lnDC, LOGPIXELSX)

? lnPixelsPerInchY, lnPixelsPerInchX

lnPrinterMarginLeft = GetDeviceCaps(lnDC , PHYSICALOFFSETX)
lnPrinterMarginTop  = GetDeviceCaps(lnDC , PHYSICALOFFSETY)

lnPrinterMarginLeftInch = lnPrinterMarginLeft / lnPixelsPerInchX
lnPrinterMarginTopInch  = lnPrinterMarginTop / lnPixelsPerInchY

? lnPrinterMarginTopInch, lnPrinterMarginLeftInch

DeleteDC(lnDC) 
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform