Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!oliveb!felix!dhw68k!thecloud From: thecloud@dhw68k.cts.com (Ken McLeod) Newsgroups: comp.sys.mac.programmer Subject: Re: Odd scrollbar behavior with TrackControl Message-ID: <13726@dhw68k.cts.com> Date: 24 Oct 88 10:02:28 GMT References: <942@ccnysci.UUCP> Reply-To: thecloud@dhw68k.cts.com (Ken McLeod) Organization: Wolfskill residence; Anaheim, CA (USA) Lines: 50 In article <942@ccnysci.UUCP> alexis@ccnysci.UUCP (Alexis Rosen) writes: >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 > >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. I had this happen to me also, using LSP 1.11a, when converting some code that had worked just fine in the old System 3.2 days. In my case, I hadn't declared my actionProc to have any arguments! Oops. You didn't post your "Scroller" procedure, so my guess is this: your actionProc needs to declare its arguments (see IM vol 1 p 324). PROCEDURE Scroller(theControl:ControlHandle; partCode:integer); BEGIN {handle text scrolling} END; rather than PROCEDURE Scroller; BEGIN END; {wrong!} If the arguments aren't declared, you'll get garbage instead of the correct ControlHandle. Hope this was helpful... -- ========== ....... =========================================== Ken McLeod :. .: uucp: {spsd, zardoz, felix}!dhw68k!thecloud ========== :::.. ..::: InterNet: thecloud@dhw68k.cts.com //// ===========================================