Recent

Author Topic: [SOLVED] TControlScrollBar.ClientSize logic wrong?  (Read 157 times)

dsiders

  • Sr. Member
  • ****
  • Posts: 293
[SOLVED] TControlScrollBar.ClientSize logic wrong?
« on: May 23, 2020, 06:52:32 pm »
I stumbled across this in controlscrollbar.inc:

Code: Pascal  [Select][+][-]
  1. function TControlScrollBar.ClientSize: integer;
  2. begin
  3.   if Kind = sbVertical then
  4.     Result := FControl.ClientWidth
  5.   else
  6.     Result := FControl.ClientHeight;
  7. end;
  8.  

It seems to return the wrong value for the orientation in Kind. A vertical scroll bar should be getting the Height of the control, and not its Width.  And a horizontal one would be using the Width and not the Height.

Right? Or have I missed something obvious?
« Last Edit: May 23, 2020, 08:03:58 pm by dsiders »
Lazarus 2.1 (SVN) / FPC 3.0.4 / Windows 8.1 64-bit

jamie

  • Hero Member
  • *****
  • Posts: 2935
Re: TControlScrollBar.ClientSize logic wrong?
« Reply #1 on: May 23, 2020, 07:01:11 pm »
Well kind of twisted but that is how things are ..
 >:(
Number 1 at blue screen app creations!

wp

  • Hero Member
  • *****
  • Posts: 7081
Re: TControlScrollBar.ClientSize logic wrong?
« Reply #2 on: May 23, 2020, 07:39:38 pm »
No I think this is correct, look at the comments in the interface declaration. It's not about the size of the scrollbar but about the control it is attached to. Assume a vertical scrollbar. Then the height of the client is equal to the height of the scrollbar - if TControlScrollbar.clientSize would return that the value would be needless. But when the width of the client is returned by the function TControlScrollbar.ClientSize then this is useful information.
« Last Edit: May 23, 2020, 07:41:31 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

dsiders

  • Sr. Member
  • ****
  • Posts: 293
Re: TControlScrollBar.ClientSize logic wrong?
« Reply #3 on: May 23, 2020, 08:03:39 pm »
After looking at ClientSizeWithBar, ClientSizeWithoutBar, and how it's being used in TScrollingWinControl... I see the error in my assumption.

No problem, so problem solved.

Thanks.
Lazarus 2.1 (SVN) / FPC 3.0.4 / Windows 8.1 64-bit

 

TinyPortal © 2005-2018