[comp.sys.mac.programmer] How do I get the slot number for the _MAIN_ Screen?

busey@milton.u.washington.edu (Thomas Busey) (05/07/91)

I'm sure that this question has been asked before, but how do I get
the slot number for the Main screen (i.e. the one with the menu
bar in it).  Thanks for responding.
Tom Busey
busey@milton.u.washington.edu
University of Washington
{^^^  A stone's throw away from Nintendo and Microsoft- probably a
good reason to throw stones!}

russotto@eng.umd.edu (Matthew T. Russotto) (05/08/91)

In article <1991May7.145602.21514@milton.u.washington.edu> busey@milton.u.washington.edu (Thomas Busey) writes:
>I'm sure that this question has been asked before, but how do I get
>the slot number for the Main screen (i.e. the one with the menu
>bar in it).  Thanks for responding.

foo()
{
	GDHandle gd;
	int mainslot

	gd = GetMainDevice();
        mainslot = (*GetADCtlEntry((*gd)->gdRefNum))->dCtlSlot
}

AuxDCEHandle GetADCtlEntry(refnum)
unsigned long refnum;
{
	return *(*((AuxDCEHandle **)0x11c) + (refnum ^ 0xFFFFFFFF));
}

--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
     .sig under construction, like the rest of this campus.

davet@cmi.com (David Temkin) (05/08/91)

References:<1991May7.145602.21514@milton.u.washington.edu> <1991May7.202841.23551@eng.umd.edu>

In article <1991May7.202841.23551@eng.umd.edu> russotto@eng.umd.edu 
(Matthew T. Russotto) writes:

> In article <1991May7.145602.21514@milton.u.washington.edu> 
busey@milton.u.washington.edu (Thomas Busey) writes:
> >I'm sure that this question has been asked before, but how do I get
> >the slot number for the Main screen (i.e. the one with the menu
> >bar in it).  Thanks for responding.
> 
> foo()
> {
>         GDHandle gd;
>         int mainslot
> 
>         gd = GetMainDevice();
>         mainslot = (*GetADCtlEntry((*gd)->gdRefNum))->dCtlSlot
> }

etc, etc.

Alternately, you can call GetMainDevice() and then get the base address of 
the pixmap -- either through the PixMap record directly, or, if 32-bit 
QuickDraw is installed, through GetPixBaseAddr().

The base address is of the form FsXXXXXX (hex), and the second hex digit 
(s) is the slot number. (This is documented in Designing Cards & Drivers). 


David Temkin
Center for Machine Intelligence, EDS Corp.
davet@cmi.com