Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!bbn.com!nic!chaos.cs.brandeis.edu!chaos!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: Calling Think C objects from MyUserItem() Message-ID: Date: 1 Oct 90 21:28:57 GMT References: <1990Sep30.012402.7195@ux1.cso.uiuc.edu> Sender: @chaos.cs.brandeis.edu Organization: Symantec Corp. Lines: 43 In-Reply-To: jason@ux1.cso.uiuc.edu's message of 30 Sep 90 01:24:02 GMT If you have a callback (in a code resource or application) that uses objects, you must make sure that your jump table pointer is correct, since object use the jump table to dispatch their methods. In code resources, A4 points to the jump table. What you should do is something like: void LineBox::DoAbout(DialogPtr aboutBox) { int itemHit; RememberA4(); ShowWindow((WindowPtr) aboutBox); SetWRefCon((WindowPtr) aboutBox, (long) this); do { ModalDialog(filter, &itemHit); } while (itemHit != OKItem); } static pascal Boolean filter(DialogPtr theDialog, EventRecord *theEvent, short *itemHit) { Boolean result = FALSE; switch(theEvent->what) { /* ... other cases ... */ case nullEvent: SetUpA4(); ((LineBox *)GetWRefCon((WindowPtr) theDialog))->Idle(); RestoreA4(); break; default: break; } return result; } This method works the same for user item draw procedures, as well. -phil shapiro, symantec tech support -- Phil Shapiro phils@chaos.cs.brandeis.edu