Recent

Author Topic: TScrollingWinControl missmatch?  (Read 5798 times)

wotanica

  • Guest
TScrollingWinControl missmatch?
« on: September 18, 2010, 11:42:45 pm »
Looking over the Lazarus code i spotted this:

Code: [Select]
function TScrollingWinControl.HasVisibleScrollbars: boolean;
begin
  Result := (VertScrollBar <> nil) and VertScrollBar.Visible and
            (HorzScrollBar <> nil) and HorzScrollBar.Visible;
end;

Shouldent that be OR? E.g:

Code: [Select]
function TScrollingWinControl.HasVisibleScrollbars: boolean;
Begin
  if not (csDestroying in componentstate) then
  Begin
    result:=( assigned(vertscrollbar)
    and vertscrollbar.visible )
    or
    ( assigned(horzscrollbar)
    and horzscrollbar.visible );
  end else
  result:=False;
end;

There may be a horizontal scrollbar visible, but that would be ignored if the vertical scrollbar is not assigned/visible. I realize that both objects (scrollbars) are created in the constructor, but if the vertical scrollbar is invisible, the horizontal state will be eliminated from the boolean expression?
« Last Edit: September 19, 2010, 12:01:59 am by wotanica »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
Re: TScrollingWinControl missmatch?
« Reply #1 on: September 19, 2010, 05:22:41 pm »
The plural form of HasVisibleScrollbars, imply that both must be there :)
But indeed it doesn't make sense to me. Nowhere in the LCL this function is used, so I don't know what it is supposed to do. I'll ask others.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

wotanica

  • Guest
Re: TScrollingWinControl missmatch?
« Reply #2 on: September 19, 2010, 10:39:50 pm »
Yes, i figured it had to mean both since it was plural. But since both objects are created in the constructor explicitly - the assigned() checks will always return true unless the component is being destroyed (hence i figured checking for csDestroying would be better). But both horizontal and vertical scrollbars may not be visible, either one can be visible or invisible depending on the content.

In delphi this one is used to determine if there are any scrollbars visible during loading, assignment etc. I seem to remember that it's particularly called when cleaning up a view (f.ex in an imageviewer, this would be called to check if the scrollbars needs to be reseted prior to loading etc.)
« Last Edit: September 19, 2010, 11:47:18 pm by wotanica »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
Re: TScrollingWinControl missmatch?
« Reply #3 on: September 20, 2010, 05:49:15 pm »
I looked in my delphi and I couldn't find it, so I thought it was a laz only. Where is it implemented ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker