Path: utzoo!attcan!uunet!samsung!olivea!apple!well!smoke From: smoke@well.sf.ca.us (Nicholas Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: How do I get a handle for an existing window? (Think Pascal) Message-ID: <21099@well.sf.ca.us> Date: 9 Oct 90 17:34:17 GMT References: <1990Oct6.063726.19882@agate.berkeley.edu> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 52 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. You couldn't do it that way: Think Pascal patches the function in question (FrontWindow) so that it never returns a Think Pascal window-- only windows your program creates. (By the way, it returns a ptr to windows; windowRecords should never be allocated in a relocatable fashion.) Pascal can't interfere with the window record's linked list of windows, however. So if you bring up a topmost but invisible window, take the ptr to it which NewWindow returns, and look through the list starting at WindowPeek(theWindow)^.nextWindow, you'll eventually find one such that WindowPeek(someWindow)^.titleHandle^^='Drawing'. You can change this title with SetWTitle. >There's an assembly language constant called, I think, WindowsList, or somethinglike that, but THINK Pascal doesn't recognize it, so I can't get at the >first entry in the system's linked list of windows. I also can't find >any other traps that return a window handle unless you already have some >other window handle to pass them. (Unless of course you create brand >new windows, which is not what I need to do.) To access WindowList from Pascal: const WindowList=$9D6; type longPtr:^longint; var aWind:WindowPeek; begin aWind:=WindowPeek(longPtr(WindowList)^); ... >I assume there's some simple solution that I as a mere novice creeping >over from the MS-DOS world haven't yet encountered? > Both of these are rather klunky solutions, and depend on specific implementations of Pascal and low-memory. The difference between the drawing window and one you create yourself is minimal--why not take the plunge? -- --- * --- Nicholas Jackiw Smoke@well.sf.ca.us | Jackiw@cs.swarthmore.edu Key Curriculum Press, Inc. Applelink: D3970 | (415) 548-2304 --- * ---