Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!peregrine!ccicpg!cci632!ph From: ph@cci632.UUCP (Pete Hoch) Newsgroups: comp.sys.mac.programmer Subject: Re: scroll bar problem Keywords: programming issue Message-ID: <27714@cci632.UUCP> Date: 5 Apr 89 17:13:57 GMT References: <425ca822.1285f@maize.engin.umich.edu> <2642@masada.cs.swarthmore.edu> Distribution: usa Organization: CCI, Communications Systems Division, Rochester, NY Lines: 56 jackiw@cs.swarthmore.edu (Nick Jackiw) writes: > rpitt@caen.engin.umich.edu (Raymond Jeczen Pittman) writes: > > I am writing an application that uses multiple windows and I would ^^^^^^^^ ^^^^^^^ > > like to know how I can access the control list in the window record > > to reference a particular controlhandle such as the scroll bars. I > > don't declare my scroll bar handles globally, I like to keep it ^ ^^^^ ^^ ^^^^ ^^ > > dynamic. The control is declared locally in a procedure but the ^^^^^^^ > > control is tagged to the window with the NewControl rom call. > > Any ideas? > > Thanks. > > R.J. Pittman rpitt@caen.engin.umich.edu > ---- > Sure you can do it this way if you want. TheWindow^^.ControlList heads a > linked list of all of your controls. How do you recognize a particular > control (e. g. horiz scroll) once you've got the ControlList? You'll have > to slap an identifying constant into the control's RefCon field. Or since you are in control of how the window is built you can always add the vertical control first and the horizontal control next. Then follow with any ofther controls you may want in that window. Then when you walk the control linked list you will know that the first control is the vertical and the second is horizontal. > At this point you should begin to wonder how dearly you wish to stick to > those principles of application hygene learned in CS courses. While you > have no global variables, and therefore are guaranteed to enforce "side- > effect-free" discipline, you DO have a global declaration of the identifying > constant, which makes your code just as difficult to read as a global var; > AND you lose efficiency because you have to search the window's entire > control list instead of having a variable already pointing to your control. This can still be done in a "clean" manner by putting all of you scrollbar handleing routines in one unit. The unit would have routines for adding scroll bars, adjusting scrollbars, and adjusting the window content based on the value od the scroll bars. There does not have to be any side effects and you remove the need for your global variables. > As long as you document thoroughly that a routine relies upon, or sets, a > global var, why not use one? Their disadvantages are all theoretical, their > advantages are all immensely practical. The oringinal poster stated that he was writting a program with multiple windows. Now if the program is to be artificialy limited to 20 windowes then an array of control handles could be easily used. But if you want to remove the window limit, maintaining a list of global controlHandles in no longer "immensely preactical". > | nicholas jackiw | jackiw%campus.swarthmore.edu@swarthmr.bitnet | Pete Hoch Computer Consoles, Inc. ph@cci632.cci.com