[comp.sys.mac.programmer] Chooser and printers

ralph@computing-maths.cardiff.ac.uk (Ralph Martin) (10/17/88)

How can an application program tell if a user has used the "Chooser"
to switch printers? Is there a global that records the current choice?

Thanks, Ralph
-- 
Dr Ralph Martin
Department of Computing Mathematics
University of Wales College of Cardiff
PO Box 916
Cardiff
CF2 4YN
United Kingdom

phil@mva.cs.liv.ac.uk (10/18/88)

In article <553@cf-cm.UUCP>, ralph@computing-maths.cardiff.ac.uk writes:
> How can an application program tell if a user has used the "Chooser"
> to switch printers? Is there a global that records the current choice?
> 
Well, the System file contains a STR resource numbered -8192 that contains
the name of the currently chosen printer.  Since System is open all the
time from your application you should just be able to use GetResource to
get a handle to the string and then double dereference it to get the string
itself. (I think)

Phil Jimmieson,           ***************************************************
Computer Science Dept.,   *        ** Note New Address & UserName **        *
Liverpool University,     * JANET : PHIL@UK.AC.LIV.CS.MVA                   *
Merseyside, England,      * ARPA  : PHIL%mva.cs.liv.ac.uk@cunyvm.cuny.edu   *
L69  3BX                  *                                                 *
                          * old address SQPHIL@UK.AC.LIV.CSVAX may work     *
(UK) 051-794-3689         ***************************************************

> Dr Ralph Martin
> Department of Computing Mathematics

anson@spray.CalComp.COM (Ed Anson) (10/19/88)

In article <553@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk (Ralph Martin) writes:
>How can an application program tell if a user has used the "Chooser"
>to switch printers? Is there a global that records the current choice?

The resource 'STR ' -8192 in the System file records the file name of the
currently chosen printer resource file ("driver").

However, your application shouldn't need to know if a change is made. Anything
it does that might depend on the printer type should be done every time a
print is requested by the user. You certainly shouldn't rely on the name of
the printer to know its type, since names can be changed quite easily.
>
>Thanks, Ralph

I hope this helps.
Ed
-- 
=====================================================================
   Ed Anson,    Calcomp Display Products Division,    Hudson NH 03051
   (603) 885-8712,      anson@elrond.CalComp.COM

kaufman@polya.Stanford.EDU (Marc T. Kaufman) (10/19/88)

In article <553@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk (Ralph Martin) writes:
>How can an application program tell if a user has used the "Chooser"
>to switch printers? Is there a global that records the current choice?

Do a PrValidate with a copy of the Print Record, and look at the high byte of
the prStl.wDev field.  This field is unique (or should be) for each device
type.  It will NOT tell you if you have switched to a different device within
a type (e.g. another LaserPrinter).

Marc Kaufman (kaufman@polya.stanford.edu)

casseres@Apple.COM (David Casseres) (10/20/88)

In article <553@cf-cm.UUCP> ralph@computing-maths.cardiff.ac.uk (Ralph Martin) writes:
>How can an application program tell if a user has used the "Chooser"
>to switch printers? Is there a global that records the current choice?

There is a global that records the name of the file containing the current
printer driver, but you shouldn't depend on that because the name might be
changed for some other language.

What you should do is call PrValidate on your current print record, and then
see whether the printer type in the print record has changed.  The printer
type is in the high byte of the wDev field.  Actually if PrValidate returns
FALSE you know the printer type has not changed, so you only have to look
at wDev if PrValidate returns TRUE.

If you do find that the user has changed the printer type -- either
deliberately with the Chooser or inadvertently by moving a document to a
different system -- then the kind thing to do is let him know before you re-
format the document!  Few applications do this, but you can easily do
this check on opening a document and each time you regain control from
a DA.  There is no standard way to notify the user, but one way would be
to call PrStlDialog.  Or you could put up your own dialog and ask the
user whether he wants reformatting, then call PrStlDialog if he says yes.
Note that the document's formatting does not HAVE to match the printer
type until printing is done.

David Casseres