Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!sun-barr!ccut!titcca!kddlab!atrpost!atr-la!alain From: alain@atr-la.atr.co.jp (Alain de Cheveigne) Newsgroups: comp.sys.mac.programmer Subject: Re: ROM doesn't unlock Handles (was: ROM unlocks Handles). Message-ID: <3902@atr-la.atr.co.jp> Date: 31 Dec 89 06:07:33 GMT References: <3875@atr-la.atr.co.jp> <4525@helios.ee.lbl.gov> <3888@atr-la.atr.co.jp> <3889@atr-la.atr.co.jp> <2632@draken.nada.kth.se> Organization: ATR International,Japan Lines: 49 In-reply-to: d88-jwa@nada.kth.se's message of 27 Dec 89 22:30:22 GMT In article <2632@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon Watte) writes: >In article <3889@atr-la.atr.co.jp> alain@atr-la.atr.co.jp (Alain de Cheveigne) writes: >>By this reasoning, WindowPtrs should have been Handles, since the user >>can open and close them in any order. To be precise, I should have written, "allocate and deallocate" instead of "open and close", since a "closed" window (e.g. hidden with HideWindow())can still be allocated. Mais vous m'aviez compris... >Well, for "historical reasons" they aren't... > >A good thing to do is to > >... > tempH = NewHandle(sizeof(WindowRecord)); > MoveHHi(tempH); > HLock(tempH); > theWindow = GetNewWindow(4711, (GrafPtr) *tempH, 0L); > SetWRefCon(theWindow, tempH); > >... > > tempH = GetWRefCon(theWindow); > CloseWindow(theWindow); > DisposHandle(tempH); > >But, alas, that means you can't use the WRefCon for something else... Wow! I always wanted to put a window record in a Handle, but never dared. Do you actually sometimes unlock the Handle and let it float? If you don't, I fail to see the advantage of a non-relocatable block at the top of the heap over one at the bottom. If you do unlock, don't you risk confusing the Window Manager or Multifinder when the block actually moves? Using the refcon is not a big problem, because you can make it point to a structure (preferably relocatable) that contains a field that points back to your Handle, along with other fields for whatever else you need to associate with the window. Alain de Cheveigne atr-la.atr.co.jp