Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!ub!uhura.cc.rochester.edu!rochester!kodak!uupsi!sunic!isgate!krafla!aries From: aries@rhi.hi.is (Reynir Hugason) Newsgroups: comp.sys.mac.programmer Subject: Re: WindowObject in Object Pascal Message-ID: <2399@krafla.rhi.hi.is> Date: 9 Nov 90 19:06:40 GMT References: <311@rusux1.rus.uni-stuttgart.de> Organization: University of Iceland Lines: 33 The way I usually solve this is to introduce a new data structure, some- thing like this: MyWindowRec = RECORD oldWindowRec: WindowRec; { what-ever stuff I need to use } END; MyWindowPeek = ^MyWindowRec; MyWindowPtr = WindowPtr; This is the same trick as Apple uses to hide the special window parameters behind a grafport, so you can simply say SetPort(myWindow). Then I stuff a windowlist structure in there too, mainly to reduce heap fragmentation if the windows are opened and closed frequently but also to enable me to check whether the window reference I receive is actually one of my windows. This is very easy to implement, you either declare a constant array of a fixed size or a dynamic list of fixed size buckets (in either case, the storage should be non-relocatable). You initialize it, by NILing some field, in each slot, that shouldn't be NIL if the slot was occupied. Then when-ever you need a window you find a free slot and pass the address of the slot to GetNewWindow. And when your through with the window you simply call CloseWindow (NOT DisposeWindow!!!). On receiving mouse-clicks you check whether the window is actually in your windowlist, if it ain't then the event is SEP (Somebody Elses Problem). Pretty strightforward stuff, eh?? Mimir (aries@rhi.hi.is) Aries, inc. /// With greetings from Sweet Mama Jankins ... and her friends.