[comp.sys.mac.programmer] driver windows

oster@dewey.soe.berkeley.edu (David Phillip Oster) (10/13/89)

In article <2903@netcom.UUCP> allanh@netcom.UUCP (Allan N. Hessenflow) writes:
>I need to display a dialog giving the user a choice between two actions
>from within a driver.

Note that a driver and a desk accesoory are essentially the same thing. If
you set the needTime bit in the driver header, then the system will call
the driver's Ctl entry point with an accRun message. At that point you can
safely put up a window. Remeber to stuff the driver's refnum (a negative
number) into the windowKind field of the window, so update, activate,
mouseDown, and keyDown events will come to your driver's Ctl entrypoint
with an accEvent message.

Remember that if you want to use the dialog manager, you should set get
the event, set the window type to dialogKind temporarily, call
dialogSelect, then restore your windowKind.

Don't bother setting the windowKind on an Alert, you can just call it.
Though, watch what resource file is currently open!

Note that when the user chooses close from the file menu, or clicks in the
close box, your driver will receive a "close" message. There is a special
error code reserved for you to return, so the caller will you know that
you just closed that window, not the whole driver.

--- According to the Constitution, the Constitution is unconstitutional:
--- David Phillip Oster            --U.S.Constitution I.10.1: "No State shall
Arpa: oster@dewey.soe.berkeley.edu --enter into any treaty, alliance, or
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu -- confederation..."

Jim.Matthews@dartvax (10/17/89)

In article <31889@ucbvax.BERKELEY.EDU>, oster@dewey.soe.berkeley.edu (David
Phillip Oster) writes:
> Note that a driver and a desk accesoory are essentially the same thing. If
> you set the needTime bit in the driver header, then the system will call
> the driver's Ctl entry point with an accRun message. At that point you can
> safely put up a window. 

I guess it depends on what you consider "safe".  Under MultiFinder, when
your driver gets the accRun call the current heap and window layer will be
those of the current application -- you may want your window to show up in
front of everything but you should be very careful about allocating memory
in someone else's application heap.  Furthermore, the current resource chain
will be that of the current app -- just because you have an open resource
file doesn't mean that you can get to it at accRun time.

These gotchas are documented (somewhat incompletely) in a recent tech note.
It seems clear that Apple does not want drivers opening windows, allocating
memory, or doing anything else of substance at accRun time.
--
Jim Matthews
Dartmouth College