Recent

Author Topic: BeginUpdate, EndUpdate for TScrollBox  (Read 2270 times)

LemonParty

  • Hero Member
  • *****
  • Posts: 537
BeginUpdate, EndUpdate for TScrollBox
« on: August 15, 2025, 07:03:43 pm »
Hello.

I have a scroll box and I change positions of many contained controls. At first time this become laggy. Is there BeginUpdate, EndUpdate for scroll box?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Thaddy

  • Hero Member
  • *****
  • Posts: 19272
  • Glad to be alive.
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #1 on: August 15, 2025, 07:11:09 pm »
use begin/endupdate from the parent control that contains all controls that change.
objects are fine constructs. You can even initialize them with constructors.

LemonParty

  • Hero Member
  • *****
  • Posts: 537
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #2 on: August 15, 2025, 07:29:09 pm »
My parent control is the scroll box. And scroll box have no methods Begin/EndUpdate.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12905
  • FPC developer.
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #3 on: August 15, 2025, 11:05:05 pm »
Yes. Delphi also has this problem, so I assume it is a win32 issue. I have a few helpers for that like

Code: Pascal  [Select][+][-]
  1. procedure Scrollbarseteventlessposition(scr:TScrollbar;def:integer);
  2. var oldevent : TNotifyEvent;
  3.  
  4. begin
  5.   oldevent:=scr.OnChange;
  6.   scr.onchange:=nil;
  7.   scr.Position:=def;
  8.   scr.OnChange:=oldevent;
  9. end;
  10. procedure Scrollbarseteventlesspositionminmax(scr:TScrollbar;def,min,max:integer);
  11. var oldevent : TNotifyEvent;
  12. begin
  13.   oldevent:=scr.OnChange;
  14.   scr.onchange:=nil;
  15.   scr.SetParams(def,min,max);
  16.   scr.OnChange:=oldevent;
  17. end;
  18.  

LemonParty

  • Hero Member
  • *****
  • Posts: 537
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #4 on: August 15, 2025, 11:20:46 pm »
I found that when set the scroll box property Visible to False, then do changes and then set to True lags not occur.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

jamie

  • Hero Member
  • *****
  • Posts: 7774
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #5 on: August 16, 2025, 08:01:13 pm »
There is a BeginFormUpdate and EndFormUpdate that may work for you.
The only true wisdom is knowing you know nothing

LemonParty

  • Hero Member
  • *****
  • Posts: 537
Re: BeginUpdate, EndUpdate for TScrollBox
« Reply #6 on: August 17, 2025, 02:39:28 pm »
There is a BeginFormUpdate and EndFormUpdate that may work for you.
This works too. Thank you.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018