Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!well!wdh From: wdh@well.sf.ca.us (Bill Hofmann) Newsgroups: comp.sys.mac.programmer Subject: Re: window Message-ID: <24737@well.sf.ca.us> Date: 12 May 91 18:05:47 GMT References: <1991May9.074917.19604@midway.uchicago.edu> Organization: Flashpoint Lines: 23 In article <1991May9.074917.19604@midway.uchicago.edu> hui@control.uchicago.edu writes: > > I am new to mac programming, this maybe a trivial question but I need >help. How to get the WindowRecord from a WindowPtr? Someone suggest >(WindowPeek)mywindow but it doesn't seem to work, and how to find the current >front window(active one)? Thank you very much. Isn't C operator precedence fun? The problem here, most likely, is that the cast has a lower precedence than the dereference, so to, for instance, look at the windowKind field, you need to say: ((WindowPeek)mywindow)->windowKind Note that that's about the only WindowRecord field you should every get at in that fashion, unless you're doing stuff with zooming windows. Use GetWRefCon and SetWRefCon for the refCon field, GetWTitle and SetWTitle for the window title, etc. FrontWindow() returns the WindowPtr of the frontmost (active) window. Note that if you're running single finder, this may not be your winodw, it may be a DA window. -Bill Hofmann