Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!tecot From: tecot@Apple.COM (Ed Tecot) Newsgroups: comp.sys.mac.programmer Subject: Re: Calling WDefProcs Manually Message-ID: <28071@apple.Apple.COM> Date: 30 Mar 89 01:35:32 GMT References: Organization: Apple Computer Inc, Cupertino, CA Lines: 37 In article rj0z+@andrew.cmu.edu (Robert George Johnston, Jr.) writes: > The problem is that I need to determine if the title bar of a window >was clicked regardless if it is an application's window, or a system >window (DA). > I devised the following solution, but it does not work. Consider: > > if (WindowPart == inSysWindow) { > VarCode = GetWVariant(TheWindow); > Result = CallPascalL(VarCode, TheWindow, wHit, TheEvent->where, > *((WindowPeek) TheWindow)->windowDefProc); > ... > } > > Result is defined as a long, and VarCode is an int. > The theory behind this statement is that I will call the windowDefProc >myself, passing all of the neccessary information to it, and it will tell >me if the title bar (dragRgn) was hit. > Problem: Result is always zero (0). This is especially confusing to >me because the reason that this statement is called is because the event >detected a mouseDown in a window, and then the windowDefProc turns around >and says that the window was NOT hit. > Anybody have any idea why this is not working? Not any specific ideas, as I'm not familiar with the syntax of CallPascal. However, you should be locking the definition function before calling it and restoring the bits afterwards: saveHBits := HGetState(defProc); HLock(defProc); CallPascal... HSetState(defProc, saveHBits); You might want to make sure that CallPascal is passing the parameters to the definition function correctly. A little tracing with MacsBug or TMON should tell you what is going on. _emt