Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cs.utexas.edu!husc6!cmcl2!rocky8!cucard!ccnysci!alexis From: alexis@ccnysci.UUCP (Alexis Rosen) Newsgroups: comp.sys.mac.programmer Subject: Odd scrollbar behavior with TrackControl Message-ID: <942@ccnysci.UUCP> Date: 22 Oct 88 06:23:11 GMT Reply-To: alexis@ccnysci.UUCP (Alexis Rosen) Lines: 51 In the last week I built a few utilities to make my life easier. They are not real complicated- they don't have event loops, for example. I didn't expect much trouble, and indeed for the most part everything went smoothly. There was one big problem, however. For the help screen I put up, I wanted a working scrollbar. So I built a DLOG & DITL & CNTL, and that seemed to work okay. Then I wrote this bit of code to handle thumb dragging (before I did the ActionProc for the scroll arrows): WHILE iNo <> 1 DO BEGIN ModalDialog(NIL, iNo); IF iNo = 2 THEN BEGIN TEScroll(0, -tx^^.lineHeight * (GetCtlValue(ControlHandle(item)) - pos),tx); pos := GetCtlValue(ControlHandle(item)) END END (BTW, this is in LSP 1.11) Everything still worked fine. Except- When I dragged the thumb, it didn't drag a grey outline of the thumb the way it ordinarily does. It drew a two pixel thick box that was inset one pixel from the regular thumb, and dragged that around. This was weird, but it didn't bother me much. What did bother me was the crash I kept getting when I defined an ActionProc for the scrollbar control. I said: SetCtlAction(ControlHandle(item), @Scroller); just before starting the ModalDialog loop. Scroller is a procedure that handles clicks in the arrows and grey regions. The wierd thing is that the ActionProc worked just fine. It did everything it was supposd to. BUT- now, the instant I clicked on the thumb, the machine would crash. The debugger showed me that when I was clicking in the thumb, my ActionProc was passed a bad ControlHandle. Clicks elsewhere passed the correct handle. This was so annoying that I skipped ModalDialog and did everything in a window. No luck. Calling FindControl and TrackControl myself didn't improve things at all. In the end, I brute-forced it by saying IF TestControl(scrl, evnt.where) = inThumb THEN i := TrackControl(ctrl, evnt.where, NIL) ELSE i := TrackControl(ctrl, evnt.where, Pointer(-1)); which means that if it's in the thumb, don't do the ActionProc, otherwise go do it. Does anyone have any idea what's going on??? ---- Alexis Rosen alexis@dasys1.UUCP or alexis@ccnysci.UUCP Writing from {allegra,philabs,cmcl2}!phri\ The Big Electric Cat uunet!dasys1!alexis Public UNIX {portal,well,sun}!hoptoad/