Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!aplcen!haven!umd5!zben From: zben@umd5.umd.edu (Ben Cranston) Newsgroups: comp.sys.mac.programmer Subject: Re: Window Scrolling Problem Summary: Are you sure the procedures are Pascal-calling-sequence? Message-ID: <5764@umd5.umd.edu> Date: 11 Dec 89 17:31:01 GMT References: <1989Dec8.164905.13550@aucs.uucp> Reply-To: zben@umd5.umd.edu (Ben Cranston) Distribution: na Organization: University of Maryland, College Park Lines: 72 In article <1989Dec8.164905.13550@aucs.uucp> 850860w@aucs.UUCP (VINCENT W. WHYNOT) writes: > I'm using TrackControl() passing it an action procedure > to do continuous scrolling. I should state that I am programming in > LightSpeed C version 2.15. Originally, no scrolling was taking place at all, > but I fixed that problem by reversing the parameters of the action procedure. > After reversing the parameters of the action > procedure, continuous scrolling would take place while the mouse was held > down in the scroll bar. But it will only do it once! If I release the mouse > button and try scrolling again, there is no result! I cannot even move the > thumb. From the observation that reversing the arguments made it work, it would seem like the action procedure is expecting the C calling sequence rather than the Pascal calling sequence. The argument orders are reversed between the two. Unfortunately, there is another important differance between the two calling sequences. In Pascal the callEE pops the arguments off the stack, while in C the callER pops them. This mismatch would not manifest itself until the procedure returns, hence your works-only-once behaviour. I don't know how to make Think C do this. In MPW C I just put the keyword pascal into the routine declaration, like this example taken from an actual program: /* Called periodically when button is held down in scrolling arrrow. */ pascal ScrollAction(ControlHandle hitctl,short part) { WindowPtr windp = (*hitctl)->contrlOwner; short oldval,newval,limit,setval; newval = oldval = GetCtlValue(hitctl); switch(part) { case inUpButton: newval -= 10; break; case inDownButton: newval += 10; break; case inPageUp: newval -= RectHite(windp->portRect); break; case inPageDown: newval += RectHite(windp->portRect); } limit = GetCtlMax(hitctl); setval = newval<0?0:newval>limit?limit:newval; if (setval != oldval) { SetCtlValue(hitctl,setval); ScrollContent(hitctl,oldval); UpdateWindow(windp); } } Could somebody with Think C experience post the correct solution? Private complaint: consistency of capitalization of proper names: pascal Boolean foo() ^ ^ Grump -- Sig DS.L ('ZBen') ; Ben Cranston * Network Infrastructures Group, Computer Science Center * University of Maryland at College Park * of Ulm