Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!utah-cs!utah-gr!thomas From: thomas@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: comp.sys.mac Subject: Re: Scroll bars in Modal Dialogs Message-ID: <1845@utah-gr.UUCP> Date: Fri, 14-Nov-86 03:39:33 EST Article-I.D.: utah-gr.1845 Posted: Fri Nov 14 03:39:33 1986 Date-Received: Fri, 14-Nov-86 07:54:47 EST References: <636@bunny.UUCP> Reply-To: thomas@utah-gr.UUCP (Spencer W. Thomas) Distribution: na Organization: University of Utah CS Dept Lines: 82 [Note: I am cross posting because this message came in here on net.micro.mac, so I want to make sure the original poster sees the response.] I think you are hitting a well-known bug in the handling of scroll bar controls. It is even documented in IM (if you know what you are looking for). The actionProc will be called with two arguments (the control handle and the part code), *except* when moving the thumb. In assembly language, you can do a hack to try and determine which it is (since you want to just return for thumb actions, anyway), by looking at the supposed "theControl" argument and seeing if it is the handle to your control. This is not certain, since the garbage on the stack could possibly have the same value you are looking for. In LSC, there seems to be nothing you can do about this. The problem is that the actionProc is a "pascal" procedure, so it will unstack the arguments on return. If it was called with NO arguments, this can be a disaster. The problem comes up worst when using controls inside a dialog, since you don't have the option of whether you pass an actionProc based on which part of the control is hit. If the control is in an ordinary window, you can pass a NIL actionProc when the thumb is selected. Hope this explanation makes sense, it feels a lit disjointed to me. As an example, here is an actionProc I wrote using Sumacc. /* * XL_ScrollAdj - Scroll an adjuster control. * Since this is called from inside a dialogue, we have no control * over what part of the scroll bar the user may have chosen. If the * thumb was picked, this routine will be called with no arguments. * Use a kludge to detect this. If args were passed, pick them with * getpargs into the struct below. */ struct TCargs { /* args passed from Pascal TrackControl */ short theCode; ControlHandle whichControl; }; XL_ScrollAdj(args) struct TCargs args; { register int i; struct TCargs a; /* Oh what a kludge. If called because user is moving thumb * directly, no args are passed. Hopefully, this will detect * that. We don't want to unstack the args if there aren't any! * * Note also dependency on a single global adjuster window. */ for ( i = 0; i < 7; i++ ) if ( args.whichControl == XL_Adjust_wind.u.adj.adjCtl[i] ) break; if ( i >= 7 ) return; /* nope, no match, so no args */ /* Getpargs pops the args off the stack */ getpargs(&a, sizeof a); switch( a.theCode ) { case inUpButton: SetCtlValue(a.whichControl,GetCtlValue(a.whichControl)-1); break; case inDownButton: SetCtlValue(a.whichControl,GetCtlValue(a.whichControl)+1); break; case inPageUp: SetCtlValue(a.whichControl,GetCtlValue(a.whichControl)-10); break; case inPageDown: SetCtlValue(a.whichControl,GetCtlValue(a.whichControl)+10); break; } XL_adjustItem = i + 1; /* end-run around DialogSelect */ } -- =Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)