Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!pt.cs.cmu.edu!henry.ECE.CMU.EDU!hairston From: hairston@henry.ECE.CMU.EDU (David Hairston) Newsgroups: comp.sys.mac.programmer Subject: Re: Disabling menus when DA's are closed Message-ID: <12263@pt.cs.cmu.edu> Date: 6 Mar 91 22:00:21 GMT References: <1.27D17B52@mmug.edgar.mn.org> Organization: Gaia II Lines: 36 [jspencer@p510.f22.n282.z1.mmug.edgar.mn.org (Jim Spencer) writes:] [] Eric Hicks writes in a message to All [] [] EH> Just a quick question that is quite probably rather simply solved. [] EH> An application I'm writing never uses the edit menu while my [] EH> main window is frontmost. (ie active) I've dimmed the menu, which [] EH> is easily accomplished in ResEdit. My problem occurs with DA [] EH> suppport. I can enable the menu when the DA comes up easily, [] EH> and I also figured out how to tell when the user has chosen close [] EH> from my file menu as a way to close a DA. My Problem occurs when [] EH> the user, clicks the close box of a DA. How can I find out when [] EH> this has happened so that I can dim the edit menu? I have a solution [] ... stuff deleted ... [] [] You should be disabling the menu whenever the DA's window is not in front. [] In your main event loop, check FrontWindow. If it is your window, then [] disable the menu. you should adjustMenus() just prior to grabbing an event in your main loop. this action keeps your menu interface uptodate with respect to the front window. however, don't go overboard in adjustMenus(). you can determine the "kind" of window in front by using FrontWindow() and checking the value of ((WindowPeek) frontWindow)->windowKind. if this is negative the front window is a system window (i.e. a DA window). if this value is 2 then the window is an alert/dialog window. if this value is 8 (or better, you can set it yourself) then its an application window. when disabling/enabling an entire menu don't forget to DrawMenuBar() to show the change (you don't want to DrawMenuBar() for every call to adjustMenus(), just when the menu bar needs updating). for more details see Inside Macintosh Vol. I, Chap.s 9 & 11 (Window & Menu Managers). -dave- hairston@henry.ece.cmu.edu