Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: A couple of problems a beginner is having. . . Message-ID: <29911@ucbvax.BERKELEY.EDU> Date: 1 Jul 89 03:31:34 GMT References: <42687@tiger.oxy.edu> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 114 In article <42687@tiger.oxy.edu> adams.e@oxy.edu (Erik Adams) writes: > 1.) If I move an application window on top of a system >window (the control panel, for example), and then move it away, >the system window is _not_ updated. You mousedown handleer should look like this: /* GoMouseDown - dispatch on the mousedown */ private void GoMouseDown(theEvent)EventRecord *theEvent;{ WindowPtr whichWindow; Integer i; i = FindWindow(theEvent->where, &whichWindow); switch(i){ case inMenuBar: GoMenuBar(theEvent); break; case inGoAway: GoAway(theEvent, whichWindow); break; case inGrow: GoGrow(theEvent, whichWindow); break; case inContent: GoContent(theEvent, whichWindow); break; case inSysWindow: SystemClick(theEvent, whichWindow); break; case inDrag: GoDrag(theEvent, whichWindow); break; case inZoomOut: case inZoomIn: GoZoom(theEvent, whichWindow, i); break; } } It is clear that you forgot the "inSysWindow" case. > 2.) I can not get a scroll bar in a modal dialog to work. >Here is what I am currently doing: I pass to ModalDialog a >pointer to a FilterProcedure. The Filterprocedure checks to see >where theEvent is. If theEvent is in the scroll bar, I call >TrackControl, passing it an ActionProcedure. you are basically doing the right thing. The biggest thing you are forgetting is that the filter procedure sees the mouse in global coordinates. Here is how I handle this. (Note: this is a fragment. I stick a pointer to an array of procedure pointers in the refCon of the control, to do the actual work of the scroll bar. All procs but the thumb proc are responsible for doing a SetCtlValue() to set the control to a new value.) /* ModifyFilter - the dialog event filter */ private pascal Boolean ModifyFilter(dp, event, itemp) DialogPtr dp;EventRecord *event;Integer *itemp;{ GrafPtr savePort; Point where; GetPort(&savePort); SetPort(dp); if(event->what == mouseDown){ where = event->where; GlobalToLocal(&where); if(PtInRect(where, &(**GetCIHandle(SLIDER)).contrlRect) && TrackScroll(where)){ event->what = nullEvent; } } SetPort(savePort); return FALSE; } /* ControlProc - return the appropriate Pascal procedure */ ProcPtr ControlProc(theControl, part)ControlHandle theControl;Integer part;{ Integer i; ProcPtr *p; switch(part){ case inUpButton: i = UPPROC; break; case inDownButton: i = DOWNPROC; break; case inPageUp: i = PAGEUPPROC; break; case inPageDown: i = PAGEDOWNPROC; break; case inThumb: i = THUMBPROC; break; } if(NIL == (p = (ProcPtr *) GetCRefCon(theControl))){ return NIL; } return (ProcPtr) p[i]; } /* TrackScroll - track a scroll bar. takes a pointer to a vector of * procedures in the refcon of the scroll bar, and calls the appropriate * one repeatedly, as appropriate. */ Boolean TrackScroll(where)Point where;{ ControlHandle theControl; Integer part, oldVal; ProcPtr ControlProc(); SubrPtr *p; if(0 != (part = FindControl(where, thePort, &theControl)) ){ if(inThumb == part){ oldVal = GetCtlValue(theControl); p = (SubrPtr *) GetCRefCon(theControl); (*p[THUMBINITPROC])(theControl); } if(inThumb == TrackControl(theControl, where, ControlProc(theControl, part))){ p = (SubrPtr *) GetCRefCon(theControl); (*p[THUMBDONEPROC])(theControl, oldVal); } return TRUE; }else return FALSE; } --- David Phillip Oster --When you asked me to live in sin with you Arpa: oster@dewey.soe.berkeley.edu --I didn't know you meant sloth. Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu