Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!agate!shelby!rutgers!att!cbnewsk!ech From: ech@cbnewsk.att.com (ned.horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: How do I get a handle for an existing window? (Think Pascal) Message-ID: <1990Oct9.181253.6137@cbnewsk.att.com> Date: 9 Oct 90 18:12:53 GMT References: <248@farcomp.UUCP> Organization: AT&T Bell Laboratories Lines: 30 From article <248@farcomp.UUCP>, by murat@farcomp.UUCP (Murat Konar): > In article <1990Oct6.063726.19882@agate.berkeley.edu> bmyers@garnet.berkeley.edu (Brian Myers) writes: >>I want to change the title of the Pascal Drawing window from "Drawing" to >>something else. I could probably do it by using ShowWindow to bring >>the window to the front and the calling the function that gives you the >>handle of the active window, but I want a more versatile algorithm that >>doesn't require bringing the window to the front. > First of all, windows are referred to by pointers not handles. Don't ask me > why. > Anyhow, there is a call named FrontWindow that takes no arguments and returns > a pointer to the front most window. Since all windows of an application are > maintained in a linked list, you can walk down the list until you find the > window you want. The low-memory global is called WindowList, and it's a WindowPeek located at $9D6. From Think Pascal you need something like FUNCTION WindowList : WindowPeek; INLINE $2eb8, $09d6; Mr. Konar's suggestion will work just fine if there is at least one visible window in front of the window you seek. Notice, however, that FrontWindow returns the frontmost VISIBLE window, and hence may even return nil if all the app's windows are currently hidden. Yes, I've been burned by this one... =Ned Horvath=