Path: utzoo!attcan!uunet!snorkelwacker!usc!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Trap patch questions Message-ID: <5755@helios.ee.lbl.gov> Date: 7 Jun 90 17:44:11 GMT References: <1101@haydn.nsc.com> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Berkeley Systems, Inc. Lines: 45 X-Local-Date: 7 Jun 90 10:44:11 PDT In article <1101@haydn.nsc.com> mcdan@dtg.nsc.com (Eric McDaniel) writes: #Reply-To: mcdan@dtg.nsc.com #Distribution: # #I am trying to write a patch to display a dialog box #under certain circumstances when an application is #launched, and am having a few problems: # #1. At first I tried patching the _Launch and _Chain #traps, but some launching utilities (notably OnCue) #apparently don't use these traps, as my code was not #always executed. I now patch _LoadSeg and check if #the segment number being loaded is #1 before calling #my code. It works, but seems less efficient since _LoadSeg #can be called any number of times within an application. This is an adequate solution. In fact MultiFinder itself doesn't use the Launch trap. #2. When I call ShowWindow to display the dialog box, #I consistently get some sort of system error. I checked #the DialogPtr and all associated handles, and everything #seems to be valid and on the system heap. I'm guessing #the problem has something to do with setting up A5 or #the GrafPort correctly. You got it. You have to perform the standard litany of manager initialization calls, including InitGraf, InitWindows, etc. It doesn't seem to be a problem to do this and then have the application do it again. #Could my use of a 'tail-patch' be the problem, and if #so, how else could I write this thing? A tail patch is probably not a problem, but it is also probably unnecessary for what you are trying to do. A simple head patch of LoadSeg would be adequate. Good luck! ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------