Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ncar!boulder!bernard From: bernard@boulder.Colorado.EDU (Bernie Bernstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C 4.0 CStaticText problem Message-ID: <17690@boulder.Colorado.EDU> Date: 3 Mar 90 00:25:20 GMT References: <17678@boulder.Colorado.EDU> Sender: news@boulder.Colorado.EDU Reply-To: bernard@boulder.Colorado.EDU (Bernie Bernstein) Organization: University of Colorado, Boulder Lines: 57 In article <17678@boulder.Colorado.EDU> bernard@piper.colorado.edu (Bernie Bernstein) writes: >In the AdjustBounds() definition in CStatic Text, the right bounds is >adjusted to one greater than the actual calculation. This makes room >for an extra character in the bounds. Why is this done was it a >mistake or is this +1 there for a reason? I prefer to adjust for the >extra size myself. > >void CStaticText::AdjustBounds() >{ > ... >} > >I removed this in my copy of it, but I just want to know if there is >any reason to put it back in. > Tiny edit had problems with line length and boundaries when I compiled it with my modified AdjustBounds. You can try it for yourselves in case you care. But I set the line length to -1 in TinyEdit, with the original version of AdjustBounds, and that is where the problem arises. The horizontal scroll bar thinks the bounds is a little bigger than the frame, so no matter what the size of the window is, you can always scroll a little bit to the right. Here is my new and improved version of AdjustBounds(). I guess you never really need a horizontal scroll bar if the lineWidth is -1, but just in case there is one for some reason, this code will fix the bug. void CStaticText::AdjustBounds() { ... int extra_bounds; ... if (lineWidth > 0) { bounds.right = lineWidth; extra_bounds = 1; } else { bounds.right = t->viewRect.right - t->viewRect.left; extra_bounds = 0; } bounds.right = bounds.right / hScale + extra_bounds; ... } > o, ,, , | Bernie Bernstein | , ,, o, ,, , | Bernie Bernstein | , ,, L>O/ \,/ \ ,| University of Colorado at boulder |/ \,,/ \ O./ ' / . `, / | office: (303) 492-8136 | / ` \ ,. ,/ / , ' | email: bernard@boulder.colorado.edu | / '' \