home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / WIN_UTL2 / PPRTR4.ZIP / READ.ME < prev   
Text File  |  1993-11-18  |  19KB  |  396 lines

  1. PPRTR.DLL copyright 1992, 1993 Paul F. Poellinger, Silent O Software
  2. -------------------------------------------------------------------
  3.                       REVISION HISTORY
  4. -------------------------------------------------------------------
  5. v4.1 -- restores "not found" error code 998 for when bad printer
  6.         name is passed to DefPrtr...left out in 4.0 conversion
  7. v4.0 -- strings passed from Prtrs, GetPrtr, DefPrtr now contain
  8.         " on xxxx.." where xxxx.. is the port.  Required to accomodate
  9.         a printer of the same type on more than one port.  Previously,
  10.         I ignored all but the first.
  11.      -- added explanatory note about how Visual Basic handles
  12.         device contexts and DEVMODES, and the allowed points
  13.         for changing stuff
  14. NOTE: Code written to work with prior versions of these functions
  15.       should be checked for compatibility with this version's.
  16.       The calling sequences are the same, but as noted above, the
  17.       strings now include port info.
  18. -------------------------------------------------------------------
  19. v3.1 -- contains a fix for user defined page length/width
  20. NOTE: When setting a user-defined pagelength or pagewidth,
  21.       you do not need to change the pagesize to user-defined
  22.       first...the pagelength/pagewidth actions do it for you.
  23.      -- added GetPort function
  24. -------------------------------------------------------------------
  25. v3.0 -- added PrtrCap, GetPrtr functions
  26. -------------------------------------------------------------------
  27. v2.0 -- fixed copies error
  28. -------------------------------------------------------------------
  29.  
  30. Included:
  31.  
  32. PPRTR    DLL                 The real deal.
  33. READ     ME                  self-reference (this).
  34. PPRTR    FRM                 .. \    Visual Basic
  35. PPRTR    MAK                   ..>    (version 3.0)
  36. PPRTR    BAS                 .. /     example of PPrtr functions.
  37. PPRTR    EXE                 .. \    Example VB3.0 program EXE and
  38. PPRTRFRM TXT                   ..>    saved text for users without
  39. PPRTRBAS TXT                 .. /     v3.0 of VB (EXE needs VBRUN300.DLL
  40. PPGLOBAL TXT                 VB constants.
  41. PRINT    TXT                 constant definitions from C header file.
  42. DEVCAP   TXT                 device cap definitions from C hdr file.
  43. PPRTR    LIB                 Import library for C.
  44. PPRTR    H                   Header file for C.
  45.  
  46. functions:
  47.  
  48.     PPrtr -- allows retrieval or change to any attribute of the default
  49.              printer
  50.  
  51.     DefPrtr -- allows you to find out or change the default printer
  52.  
  53.     Prtrs -- returns semi-colon delimeted list of available active
  54.              printers
  55.  
  56.     PrtrCap -- returns structure (VB type) containing default printer
  57.                device capabilities
  58.  
  59.     GetPrtr -- returns the name of the current default printer
  60.  
  61.     GetPort -- returns the port of the current default printer
  62.  
  63. -----------------------------------------------------------------------
  64.  
  65. function prototypes:          ( in C format ) :
  66.  
  67.     int FAR PASCAL PPrtr (HWND hwndx, int selection, int NewValue, int action);
  68.     int FAR PASCAL Prtrs (LPSTR szActives);
  69.     int FAR PASCAL DefPrtr (LPSTR szNewPrinter, LPSTR szOldPrinter);
  70.     int FAR PASCAL GetPrtr (LPSTR szPrtr);
  71.     int FAR PASCAL GetPort (LPINT szPort);
  72.     int FAR PASCAL PrtrCap (LPINT nDevCap);
  73.  
  74. -----------------------------------------------------------------------
  75.  
  76. function definitions:         ( in Visual Basic format ) :
  77.  
  78.     ******************************** PPrtr **********************************
  79.  
  80.     Declare Function PPrtr Lib "PPRTR.DLL" (ByVal hWnd As Integer, ByVal ppSelection As Integer, ByVal PPNewValue As Integer, ByVal ppAction As Integer) As Integer
  81.  
  82.           where:    hWnd ................ is a window handle
  83.                     ppSelection ......... is the selected printer device
  84.                                            attribute to get/change.
  85.                                       ... NOTE that not all printers
  86.                                            support all actions (e.g. my
  87.                                            Epson LX-800 doesn't support
  88.                                            PaperLength or PaperWidth)
  89.                     ppNewValue .......... is the value to change it to
  90.                                       ... (anything will do call is a
  91.                                            gimme, no change )
  92.                                       ... see PPGLOBAL.TXT for available
  93.                                            values
  94.                     ppAction ............ is the action requested
  95.                                       ...  0 = gimme current value
  96.                                       ...  1 = change it to ppNewValue
  97.              returns ......... integer of value of selected attribute
  98.                                 before the call
  99.                            ... 996 when the ppSelection is not supported
  100.                                    by the default printer driver
  101.                            ... 997 for a bad ppSelection code parameter
  102.                            ... 998 for a bad ppAction code parameter
  103.                            ... 999 when it can't find printer/driver info
  104.  
  105.     ppSelection:
  106.         DM_ORIENTATION = &H1
  107.         DM_PAPERSIZE = &H2
  108.         DM_PAPERLENGTH = &H4
  109.         DM_PAPERWIDTH = &H8
  110.         DM_SCALE = &H10
  111.         DM_COPIES = &H100
  112.         DM_DEFAULTSOURCE = &H200
  113.         DM_PRINTQUALITY = &H400
  114.         DM_COLOR = &H800
  115.         DM_DUPLEX = &H1000
  116.         DM_YRESOLUTION = &H2000
  117.         DM_TTOPTION = &H4000
  118.  
  119.  
  120.     Samples:
  121.  
  122.         PPrtr(hWnd, DM_PAPERSIZE, PP_UNNEEDED, PP_GIMME))
  123.         PPrtr(hWnd, DM_ORIENTATION, PP_UNNEEDED, PP_GIMME))
  124.  
  125.         PPrtr(hWnd, DM_ORIENTATION, DMORIENT_PORTRAIT, PP_CHANGE_IT))
  126.         PPrtr(hWnd, DM_PAPERSIZE, DMPAPER_LEGAL, PP_CHANGE_IT))
  127.  
  128.     C programmers...the relavent header file for this call is PRINT.H
  129.                     (in Borland C++)
  130.     ******************************** DefPrtr *******************************-
  131.  
  132.     Declare Function DefPrtr Lib "PPRTR.DLL" (ByVal newone As String, ByVal oldone As String) As Integer
  133.  
  134.        where:  newone .. is a string corresponding to what you see in the
  135.                          control panel printers dialog box.  It shows
  136.                          printer names followed by "on xxxx:" where
  137.                          xxxx is a port.  Don't use one where it says
  138.                          "on None".
  139.  
  140.                                     HP LaserJet Series II on LPT1:
  141.                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  142.                                                    ^-- all this
  143.  
  144.                          This is case insensitive, but otherwise must
  145.                          be identical.
  146.  
  147.                          Note: the printer must have been
  148.                          made "active" in the control panel
  149.                          printers applet...it'll show "None"
  150.                          for a port if it's not...e.g.
  151.  
  152.                             active -> HP LaserJet Series II=HPPCL,LPT1:
  153.                             not ----> HPGL Plotter=MGXHPGL,None
  154.  
  155.                          Note: the printer may be active on
  156.                          more than one port.  It'll show the
  157.                          additional ports on the same line
  158.                          separated by commas...e.g.
  159.  
  160.                             1 port -> HP LaserJet Series II on LPT1:
  161.                             3 ports -> HP LaserJet Series II on LPT1:, LPT2:, COM2:
  162.  
  163.                          To use the LPT2 printer, pass this:
  164.  
  165.                              HP LaserJet Series II on LPT2:
  166.  
  167.                          Passing this parameter as an empty string or
  168.                          unrecognizable string results in a 998 error, but
  169.                          does return the name of the current printer
  170.                          in the "oldone" parameter...thus, allowing
  171.                          retrieval of the name of the current default
  172.                          printer without changing anything:
  173.  
  174.                             currentptr$ = String$(255, 0)
  175.                             i = DefPrtr("", currentptr$)
  176.  
  177.        where:  oldone .. is a string in which the function will return
  178.                          the default printer before your call.
  179.  
  180.                          Save this for use as "newone" to reset the
  181.                          printer to the prior default printer when
  182.                          and if you desire to do so.
  183.  
  184.                          Note: in Visual Basic you must pre-load a
  185.                          string which is to be filled by a called
  186.                          function...e.g.
  187.  
  188.                             oldptr$ = String$(255, 0)
  189.                             i = DefPrtr("HP LaserJet Series II on LPT1:", oldptr$)
  190.  
  191.        returns:          0   = successful
  192.                          999 = Unable to write to WIN.INI ... this
  193.                                is a system problem.
  194.                          998 = The "newone" printer was not found in
  195.                                [devices] section of WIN.INI
  196.                                ... be sure you've put in all spaces
  197.                          997 = The "newone" printer was found, but it
  198.                                is not "active"...i.e. its port is
  199.                                "None"
  200.  
  201.  
  202.     Sample:
  203.        Declare Function DefPrtr Lib "PPRTR.DLL" (ByVal newone As String, ByVal oldone As String) As Integer
  204.  
  205.        //---- change to LaserJet ---------------------
  206.        oldprinter$ = String$(255, 0)
  207.        i = DefPrtr("HP LaserJet Series II on LPT1:", oldprinter$)
  208.        //----
  209.        .
  210.        .    print to LaserJet
  211.        .
  212.        //---- change back to original printer --------
  213.        dontcare$ = String$(255, 0)
  214.        i = DefPrtr(oldprinter$,dontcare$)
  215.  
  216.     ******************************** Prtrs *******************************-
  217.  
  218.     Declare Function Prtrs Lib "PPRTR.DLL" (ByVal pList As String,) As Integer
  219.  
  220.        where:  pList ... is a string for the return of a list of
  221.                          available active printers.
  222.  
  223.                          The list only contains the names of "active"
  224.                          printers.  The printer must have been
  225.                          made "active" in the control panel
  226.                          printers applet...it'll show "None"
  227.                          for a port if it's not...e.g.
  228.  
  229.                             active -> HP LaserJet Series II=HPPCL,LPT1:
  230.                             not ----> HPGL Plotter=MGXHPGL,None
  231.  
  232.                          Note: in Visual Basic you must pre-load a
  233.                          string which is to be filled by a called
  234.                          function...e.g.
  235.  
  236.                             plist$ = String$(255, 0)
  237.                             i = Prtrs(plist$)
  238.  
  239.                          The active printer names are separated by
  240.                          semi-colons (;), e.g.
  241.  
  242.                               Epson LX-800 on LPT1:;HP LaserJet Series II on LPT2:
  243.  
  244.        returns ....... 0 if no active printers found, or
  245.                        unable to access [drivers] section in WIN.INI
  246.                ....... 999 if the substring " on " cannot be found in the
  247.                        string you passed, or
  248.                ....... the length of the returned string
  249.  
  250.     ******************************** PrtrCap *******************************-
  251.     Declare Function PrtrCap Lib "PPRTR.DLL" (ndc As DEVCAP) As Integer
  252.        where:  ndc .. is a structure (VB type definition) containing the
  253.                       device capability variable definitions:
  254.  
  255.                       Type devcap
  256.                            DRIVERVERSION As Integer
  257.                            TECHNOLOGY    As Integer ' bits
  258.                            HORZSIZE      As Integer
  259.                            VERTSIZE      As Integer
  260.                            HORZRES       As Integer
  261.                            VERTRES       As Integer
  262.                            BITSPIXEL     As Integer
  263.                            PLANES        As Integer
  264.                            NUMBRUSHES    As Integer
  265.                            NUMPENS       As Integer
  266.                            NUMMARKERS    As Integer
  267.                            NUMFONTS      As Integer
  268.                            NUMCOLORS     As Integer
  269.                            PDEVICESIZE   As Integer
  270.                            CURVECAPS     As Integer ' bits
  271.                            LINECAPS      As Integer ' bits
  272.                            POLYGONALCAPS As Integer ' bits
  273.                            TEXTCAPS      As Integer ' bits
  274.                            CLIPCAPS      As Integer ' bits
  275.                            RASTERCAPS    As Integer ' bits
  276.                            ASPECTX       As Integer
  277.                            ASPECTY       As Integer
  278.                            ASPECTXY      As Integer
  279.                            LOGPIXELSX    As Integer
  280.                            LOGPIXELSY    As Integer
  281.                            SIZEPALETTE  As Integer
  282.                            NUMRESERVED  As Integer
  283.                            COLORRES     As Integer
  284.                       End Type
  285.  
  286.                       See the PPGlobal.txt file for 'bit' field masks;
  287.                       and see the VB example for sample usage.  See the
  288.                       windows SDK documentation for explanation of the
  289.                       dev cap fields.
  290.  
  291.        Returns 0 always.
  292.  
  293.     ******************************** GetPrtr *******************************-
  294.     Declare Function GetPrtr Lib "PPRTR.DLL" (ByVal DefP As String) As Integer
  295.        where:  DefP .. is a string set up to receive the name of the
  296.                        current default printer.
  297.  
  298.                        Note: in Visual Basic you must pre-load a
  299.                        string which is to be filled by a called
  300.                        function...e.g.
  301.  
  302.                           defptr$ = String$(255, 0)
  303.                           i = GetPrtr(defptr$)
  304.  
  305.       Returns 0 -- and printer name in the string if successful;
  306.                    if not, string is as you initialized it.
  307.  
  308.     ******************************** GetPort *******************************-
  309.     Declare Function GetPort Lib "PPRTR.DLL" (ByVal DefP As String) As Integer
  310.        where:  DefP .. is a string set up to receive the name of the
  311.                        current default printer port.
  312.  
  313.                        Note: in Visual Basic you must pre-load a
  314.                        string which is to be filled by a called
  315.                        function...e.g.
  316.  
  317.                           defptr$ = String$(255, 0)
  318.                           i = GetPort(defptr$)
  319.  
  320.       Returns 0 -- and printer name in the string if successful;
  321.                    if not, string is as you initialized it.
  322.  
  323. --------------------------------------------------------------------
  324. Visual Basic programmers, PLEASE READ:
  325.    Windows programs, including VB, print to a virtual printer called
  326. a Device Context, or DC.  When you start a print job by performing
  327. any print action, VB gets a new DC...this attaches printer setting
  328. data from a structure called DEVMODE.  From then till you issue an
  329. ENDDOC, setting changes like orientation or default printer are not
  330. recognized.  It appears as tho the dll calls didn't work, when in
  331. fact they worked but were ignored.
  332.    So, you must make pprtr.dll calls before your first print action,
  333. or after the ENDDOC if you want to change stuff between print jobs.
  334. --------------------------------------------------------------------
  335.    My next version will manage DCs so that setting changes can be
  336. made on the fly.  That'll allow orientation changes in mid-job, for
  337. example.  I'll also support multiple DCs, which will allow you to
  338. create print jobs to more than one printer simultaneously, or more
  339. than one job for the same printer at the same time (they print
  340. separately, not mixed).
  341.    BTW, it also contains functions for printing the screen, window
  342. or client area; printing to or from a file; printing the clipboard
  343. or capturing the screen, window or client area to the clipboard or
  344. a file; loading a file to the clipboard.  It'll print all this stuff
  345. to a fax, too, by temporarily changing the default printer to your
  346. fax...after you make a call identifying it.
  347.   If you're registered, I'll e-mail you a notice when I finish
  348. testing it...the coding's done, but testing is tedious.  Beta
  349. testers would be welcome.
  350. --------------------------------------------------------------------
  351. This DLL has been extensively tested by me and friends, but YMMV.
  352.  
  353. A tip of the pelican's beak to OsoSoft George Campbell who suggested the
  354. original idea for this DLL.
  355.  
  356. You are free to try this DLL for 30 days.
  357.  
  358. If you decide to use it thereafter, you are obligated to send $10 to
  359.                      PAUL POELLINGER
  360.                      2019 Round Lake Drive
  361.                      Houston, TX  77077
  362. Please include you e-mail address if you have one.
  363.  
  364.          -- OR --
  365.  
  366. register via Compuserve's shareware registration service by
  367. typing GO SWREG at the prompt. (Note: I only net $8.50
  368. this way :-(
  369.  
  370. After doing so, you are free to use it in your applications, and
  371. to distribute it with such applications, as long as you do not
  372. charge separately for the DLL or publish its calling conventions.
  373.  
  374. Please note that even if you paid for a diskette or CD containing
  375. this package, you must still pay the $10 registration fee for use
  376. of this DLL past the 30 day free trial.
  377.  
  378. If you paid for the earlier version, you've paid for this one.
  379. I and all those dependent on me thank you.
  380.  
  381. You are free to pass this package on to others or upload it to
  382. bulletin boards provided that 1) you do not charge for it above
  383. the cost of distribution, and 2) all parts of the package are
  384. included (see "included" at the top).
  385.  
  386. Thank you for supporting shareware.
  387. -------------------------------------------------------------------
  388. Let me know if you have any trouble or suggestions.
  389.  
  390.       Paul Poellinger
  391.         Code Wallah
  392.         Silent O Software
  393.         Purveyors of Peliware
  394.         Compuserve 70732,3576
  395.                                     11-18-93
  396.