Recent

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

dsiders

  • Hero Member
  • *****
  • Posts: 1431
[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 »
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6953
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 ..
 >:(
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 12864
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 »

dsiders

  • Hero Member
  • *****
  • Posts: 1431
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.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018