Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine printer top margin programmatically
Message
 
 
To
18/04/2006 23:59:06
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01114464
Message ID:
01114588
Views:
19
>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--
Previous
Reply
Map
View

Click here to load this message in the networking platform