Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!agate!ucbvax!tut.cis.ohio-state.edu!osu-cis!att!pegasus!ech From: ech@pegasus.ATT.COM (Edward C Horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: scroll bar problem Message-ID: <2739@pegasus.ATT.COM> Date: 4 Apr 89 08:13:31 GMT References: <2642@masada.cs.swarthmore.edu> Distribution: usa Organization: AT&T ISL Middletown NJ USA Lines: 42 In article <425ca822.1285f@maize.engin.umich.edu> rpitt@caen.engin.umich.edu (Raymond Jeczen Pittman) writes: > I am writing an application that uses multiple windows and I would > like to know how I can access the control list in the window record > to reference a particular controlhandle such as the scroll bars... From article <2642@masada.cs.swarthmore.edu>, by jackiw@cs.swarthmore.edu (Nick Jackiw): > Sure you can do it this way if you want. TheWindow^^.ControlList heads a > linked list of all of your controls. How do you recognize a particular > control (e. g. horiz scroll) once you've got the ControlList? You'll have > to slap an identifying constant into the control's RefCon field. > At this point you should begin to wonder how dearly you wish to stick to > those principles of application hygene learned in CS courses... One other "clean" solution already suggested is to put a handle to a struct in the window's refCon. Another method is to take a page from Apple's book (single-inheritance OOPLs, really). Note that WindowRecord has GrafPort as a prefix; similarly, DialogRecord has a WindowRecord as a prefix. Since a Dialog "IS A" Window "IS A" GrafPort, this makes perfectly good sense. The windowKind field is there for you to use as a tag for a "safe union." While the WindowMgr will set that to userKind (8), any value >=8 is available for your use. Hence declarations like enum { unspec = userKind, windowType1,... }; typedef struct { WindowRecord theWindow; /* my stuff ... */ } window1; are perfectly reasonable; you allocate space for a window1, pass its address to NewWindow, then set theWindow.windowKind appropriately and flesh out the other fields. The address of a window1 is usable as a WindowPtr or GrafPtr in all contexts. About the only drawback to this approach is if you want some of your windows to be non-modal dialogs (the DialogMgr wants a windowKind of 2). Not a killer, but it would be nicer if we could just set and forget windowKind. =Ned Horvath=