Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple2 Subject: Re: hiding data in a window structure Message-ID: <52850@apple.Apple.COM> Date: 14 May 91 06:39:07 GMT References: <3567@kluge.fiu.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 36 In article <3567@kluge.fiu.edu> acmfiu@serss0.fiu.edu (ACMFIU) writes: >[...] >i took a look at the window data structure and i could store the grafport >pointer in wRefCon. however, i can find this entry in a GrafPort, which is >different, to my anyway, than a window data structure you pass to NewWindow. > >oh yeah, if there's another 4-byte location free in the window grafport >i'd like to know about that too. > >albert chin Sure, the refcon is a perfectly good place to keep information that goes with each window--this way you can have an unlimited number of windows and always have access to the right data when you need it. You point out that a grafport pointer is not the same as a window pointer. That's true. But you can think of a window as an *extension* of a grafport. A grafport is the first thing in a window, and there's more stuff beyond that. So: Every window pointer is also a grafport pointer, but only *some* grafport pointers are window pointers. In your window update routine, for example, you can call GetPort to find out what window you're updating. The port at that point is guaranteed to be a window pointer, so you're perfectly free to call GetWRefCon on it to get at your data. (And, finally, there is no extra space in the grafport structure.) -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II System Software Engineer | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie:DAVE.LYONS CompuServe:72177,3233 Internet:dlyons@apple.com My opinions are my own, not Apple's.