Apple II
Technical Notes
_____________________________________________________________________________
                                                  Developer Technical Support

Apple IIgs
#82:    Controlling the Control Manager

Written by:    Dave Lyons                                            May 1990

This Technical Note describes an anomaly in the NewControl2 call in System 
Software 5.0.2 and provides a solution.
_____________________________________________________________________________

When NewControl2 creates a control, it's supposed to set the QuickDraw II port 
to the control's owner port--but it doesn't.  If the port is not already set 
properly, this can cause the system to trash memory at random.

To avoid the problem, always SetPort to the window in which you are creating 
controls before calling NewControl2.

Implications for NewWindow2

NewWindow2 can create a window and its controls in one step.  In this case, 
the port is not set to the window that was just created, before NewWindow2 
calls NewControl2 internally.  The result is that NewWindow2 cannot reliably 
create a window with an attached control list.

A solution is to do a NewWindow2 call without an attached control list, 
SetPort to the newly-created window, and then do a NewControl2 call.


Further Reference
_____________________________________________________________________________
  o  Apple IIgs Toolbox Reference, Volume 3

