[comp.sys.mac.programmer] Defaults in Page Setup dialog--HOW?

reiss@husc9.harvard.edu (Peter Reiss) (03/16/91)

I am writing a program which lets the user print data (bridge scores, but
that's not important), but rarely, if ever, would one print the data in the
standard vertical mode, but rather horizontally.  Currently I am calling the
Page Setup dialog and forcing the user to change to horizontal mode.  Is there
any way to make this a default in the dialog? Or even change this without
bringing up the dialog?  Thanks.

gurgle@well.sf.ca.us (Pete Gontier) (03/20/91)

In article <1991Mar15.195601.314@husc3.harvard.edu> reiss@husc9.harvard.edu (Peter Reiss) writes:
>I am writing a program which lets the user print data (bridge scores, but
>that's not important), but rarely, if ever, would one print the data in the
>standard vertical mode, but rather horizontally.  Currently I am calling the
>Page Setup dialog and forcing the user to change to horizontal mode.  Is there
>any way to make this a default in the dialog? Or even change this without
>bringing up the dialog?  Thanks.

Yes to both.

However, there are some caveats. No method of doing this sort of thing is
completely fool-proof. Certainly no method is supported or encouraged by
Apple. All methods will probably break when Apple revises the print
architecture.

That having been said, changing that kind of option is a simple matter
of finding a program called PrintRecordSpy. It appears regularly on
Developer CDs, and may be available at apple.com (the ftp site). You
can use the program to change options in the various Printing Manager
dialogs and see what changes are subsequently made to the print record.
You can deduce what you yourself need to change if you choose to break
the rules and do it.

If you do decide to do this, make sure you call PrValidate after altering
the print record. You want to make sure that the driver can cope with
the hacking you've done. It may still not work the way you expect, but
at least you reduce the possibility of crashing the driver.
-- 
 Pete Gontier, gurgle@well.sf.ca.us
 Software Imagineer, Kiwi Software, Inc.

tim@hoptoad.uucp (Tim Maroney) (03/23/91)

In article <1991Mar15.195601.314@husc3.harvard.edu> reiss@husc9.harvard.edu
(Peter Reiss) writes:
>I am writing a program which lets the user print data (bridge scores, but
>that's not important), but rarely, if ever, would one print the data in the
>standard vertical mode, but rather horizontally.  Currently I am calling the
>Page Setup dialog and forcing the user to change to horizontal mode.  Is there
>any way to make this a default in the dialog? Or even change this without
>bringing up the dialog?  Thanks.

To do it from the dialog, read the Tech Note on adding items to the
print dialogs.  Instead of adding any items, just do the hard-way
initialization sequence, and after the dialog is created, walk the
dialog item list or the window control list looking for a button with
the appropriate title.  Then from your item or event filter procedure,
return a fake hit on that button.

This probably seems nastier than it is.  Notice that it should have no
problems even if the print dialog changes (it will be a no-op if it
can't find the right button) and that it can readily be
internationalized.

You *can* change the print record directly, but that is much nastier
and much more sensitive to printer driver changes.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

FROM THE FOOL FILE:
"As the expert on stupid, I'll take your word for it."
  -- Richard Sexton, richard@gryphon.COM