Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's wrong with this Code?
Message
From
03/06/2005 05:33:55
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
What's wrong with this Code?
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01019741
Message ID:
01019741
Views:
87
I was very curious how to translate a Tracy's code in Message #1019602 IsPrinterDotMatric().
I do:
#define NUMCOLORS      24
#define DC_TRUETYPE    15
#define DCTT_BITMAP     1
#define COLORRES      108

cPrinter = GETPRINTER()
=APRINTERS(aPrnts)
prtPos = ASCAN(aPrnts,cPrinter,1,-1,1,8)

? IsPrinterMatrix(cPrinter, aPrnts[prtPos, 2])






FUNCTION IsPrinterMatrix(lcPrinterName, lcPort)

    LOCAL lhPrinterHandler,lbRetVal, lnDC

    lbRetVal = .f. && .f. - Not a DotMatrix Printer
                   && .t. - DotMatrixc Printer
                 
    lhPrinterHandler = 0

     DECLARE INTEGER GetDeviceCaps IN WIN32API INTEGER hdc,;
                                               INTEGER nIndex

     DECLARE INTEGER DeviceCapabilities IN winspool.drv  STRING  lpDeviceName,;
                                                         STRING  lpPort,;
                                                         LONG    iIndex,;
                                                         LONG    lpOutput,;
                                                         LONG    lpDevMode

    DECLARE INTEGER CreateDC IN gdi32 STRING lpszDriver,;
                                      STRING lpszDevice,;
                                      STRING lpszOutput,;
                                      INTEGER lpInitData
    DECLARE INTEGER DeleteDC IN gdi32 INTEGER lhDC

    lnDC = CreateDC("WINSPOOL", lcPrinterName, lcPort, 0)
    CLEAR
    ?
    ?
    ? lnDC
    ? lcPrinterName, lcPort
    ? "Colors  -", GetDeviceCaps(lnDC, NUMCOLORS)
    ? "Capabilities-",DeviceCapabilities(lcPrinterName, lcPort, DC_TRUETYPE, 0, 0)
    IF GetDeviceCaps(lnDC ,NUMCOLORS) <= 16 .AND.;
       DeviceCapabilities(lcPrinterName, lcPort, DC_TRUETYPE, 0x00, 0x00) == DCTT_BITMAP
       lbRetVal = .t.
    ENDIF
    DeleteDC(lnDC)
    CLEAR DLLS CreateDC, DeleteDC,;
               GetDeviceCaps, DeviceCapabilities

RETURN lbRetVal
But for standart HP LJ (no indexes or any other marks here) driver that comes with WindowsXP the result of the function is .t. I think I do something totaly wrong, but I can't find what.

TIA
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Next
Reply
Map
View

Click here to load this message in the networking platform