Recent

Author Topic: Incorrect behavior of scrollbox  (Read 764 times)

simone

  • Hero Member
  • *****
  • Posts: 666
Incorrect behavior of scrollbox
« on: December 21, 2023, 04:21:19 pm »
Hello everyone, consider the following simple code:

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormCreate(Sender: TObject);
  16.   private
  17.      ScrollBox : TScrollBox;
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32. begin
  33.   ScrollBox:=TScrollBox.Create(Self);
  34.   ScrollBox.Parent:=Self;
  35.   ScrollBox.Align:=alClient;
  36.   ScrollBox.Brush.Color:=clWhite;
  37.   ScrollBox.HorzScrollBar.Page:=ClientWidth;
  38.   ScrollBox.HorzScrollBar.Range:=High(integer);
  39.   ScrollBox.HorzScrollBar.Increment:=ClientWidth div 16;
  40.   ScrollBox.VertScrollBar.Page:=ClientHeight;
  41.   ScrollBox.VertScrollBar.Range:=High(integer);
  42.   ScrollBox.VertScrollBar.Increment:=ClientHeight div 16;
  43. end;
  44.  
  45. end.

Under Windows, using Lazarus 2.2.6  FPC 3.2.2 x86_64-win64-win32/win64 I have no problems.

Under Linux, using Lazarus 2.2.6 FPC 3.2.2 x86_64-linux-gtk2, when I scroll on the scrollbox, the previously invisible portion that is shown, is not white, but gray (=default color, I guess), as you can see from the attached screenshot.

Is this a bug? Do you have any tips for overcoming the problem? Thanks for the usual support.

Microsoft Windows 10/11 64 bit - Lazarus 3.8/4.0 FPC 3.2.2 x86_64-win64-win32/win64

paweld

  • Hero Member
  • *****
  • Posts: 1418
Re: Incorrect behavior of scrollbox
« Reply #1 on: December 21, 2023, 04:36:09 pm »
use:
Code: Pascal  [Select][+][-]
  1.   ScrollBox.Color:=clWhite;
instead of
Code: Pascal  [Select][+][-]
  1. ScrollBox.Brush.Color:=clWhite;
Best regards / Pozdrawiam
paweld

simone

  • Hero Member
  • *****
  • Posts: 666
Re: Incorrect behavior of scrollbox
« Reply #2 on: December 21, 2023, 04:44:34 pm »
Thanks Paweld, in fact TScrollBox.Color is the property to use to set the background color of the control. I don't know why I set the brush property whith the same name.

I wonder if the different behavior between Windows and Linux is worthy of interest.

I seems that under Windows the brush color is applied to the entire surface of the control, while under Linux (gtk2), only to the surface visible at that moment.
« Last Edit: December 21, 2023, 04:50:27 pm by simone »
Microsoft Windows 10/11 64 bit - Lazarus 3.8/4.0 FPC 3.2.2 x86_64-win64-win32/win64

simone

  • Hero Member
  • *****
  • Posts: 666
Re: Incorrect behavior of scrollbox
« Reply #3 on: December 21, 2023, 11:27:34 pm »
I tested the initial example in my post with the new Lazarus 3.0. Under Windows the behavior is now different (and more correct, in my opinion). Now:
Code: Pascal  [Select][+][-]
  1. ScrollBox.Brush.Color:=clWhite;
it does not color the control surface, which appears with its default color. I haven't had a chance to try it under Linux yet.
« Last Edit: December 21, 2023, 11:56:06 pm by simone »
Microsoft Windows 10/11 64 bit - Lazarus 3.8/4.0 FPC 3.2.2 x86_64-win64-win32/win64

 

TinyPortal © 2005-2018