Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: MacApp help needed (closing a window) Message-ID: <40173@apple.Apple.COM> Date: 10 Apr 90 07:06:02 GMT References: <90099.091150DN5@psuvm.psu.edu> Organization: Apple Computer Inc, Cupertino, CA Lines: 38 In article <90099.091150DN5@psuvm.psu.edu> DN5@psuvm.psu.edu writes: >Hi: > >I need to be able to close a MacApp window from a button placed within >that window. I have tried using the .Close method, but the system crashed >on me. My current way of doing this is to have a global variable which >is normally NIL, but if non-NIL contains a window (gWindowToClose), and >whenever my application sees that this is non-NIL, closes the window. > >I think that there should be an easier way of doing this. Perhaps the >PostEvent solution mentioned in an earlier message? D. Jay, It sounds like you are doing the right thing by calling the .Close method. If you need to close a window such as a dialog, then you just say "aWindow.Close;". If this isn't working then it sounds like you need to do some more tracking down of what is going on. For instance, where are you crashing? In MacApp's code? In yours? Why is it crashing? What is the error number or message? What can you track down by using the MacApp debugger, SADE, Macsbug, TMON, Jasik's Debugger, or the THINK debugger (if you are using THINK Pascal). Using "gWindowToClose" or posting a command are both creative solutions, but neither should be necessary. (Note: I've helped people with questions concerning odd crashing in MacApp in the past. In almost every case, it's because they were calling UnloadAllSegs when there were return addresses to non-permanently resident segments on the stack. Could this be the case?) -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions