Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!sunc.osc.edu!spencer@cgrg.ohio-state.edu From: spencer@cgrg.ohio-state.edu (Stephen N. Spencer) Newsgroups: comp.sys.mac.programmer Subject: CDEF Woes... Message-ID: <1435@gertie.osc.edu> Date: 25 Feb 91 17:56:23 GMT Sender: spencer@osc.edu Distribution: na Organization: OSU Advanced Computing Center for the Arts and Design Lines: 56 I've been experimenting with writing CDEF (Control Definitions) for a few custom-type controls (an ICON button, a floating-point slider), and have run into a problem. First, the setup: Since I want debugging messages from the CDEF, I'm not compiling it as a CODE resource and linking it into my tester application. (I have two windows in my tester app: a drawing window, and a TextEdit window. I have an 'AddMessage()' function which takes a character string and appends it to the TextEdit window -- instant scrolling debugging message window!) I'm doing the following to associate my control with the control handle: First, I make the window, set the port, and call my setup function: gDrawWindow = NewWindow(....blah blah....); SetPort(gDrawWindow); SetupCDEF(gDrawWindow); Here's the setup function: SetupCDEF(win) WindowPtr win; { Rect r; Handle h; h = NewHandle(h); *h = (Ptr)MyControl; /* MyControl() is my CDEF 'main' function. */ SetRect(&r, 160, 30, 400, 60); myCH = NewControl(win, &r, "\p", TRUE, 0, 50, 100, scrollBarProc, 0L); HLock(myCH); (*myCH)->contrlDefProc = myH; HUnlock(myCH); } This works, to a point. 'MyControl' intercepts all 'drawCntl' and 'testCntl' messages passed through the control handle 'myCH', I'm glad to report, but where it messes up is that I don't get any 'initCntl' message(s) at all. I could, of course, compile this CDEF into a stand-alone CODE resource and use ResEdit to paste it into the test application, making the requisite changes to the 'NewControl' statement, (I know how to do that). I don't want to, however. I want to see debugging messages. Is there SOME way to link a CDEF function to a control handle so that it can be compiled in together with the testing application? Thanks in advance for any help anyone out there can provide. When these CDEFs are finished, I will post them to the 'net: I'm sure they would be useful. Stephen N. Spencer |"Now you must dance the dance that you imply! ACCAD (614) 292-3416 | Your actions will follow you full circle round, The Ohio State Univ. | The higher the leap, I said, 1224 Kinnear Road | The harder the ground!" Columbus, OH 43212-1163| - Amy Ray, "Center Stage" spencer@cgrg.ohio-state.edu||71160.3141@compuserve.com||stephen_spencer@osu.edu