Recent

Author Topic: [Solved] How to lock/unlock control repainting (to eliminate flicker)?  (Read 2967 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2401
    • UVviewsoft
On Delphi I was able to use some WIn32 API (with word "Update"? I dont recall)
which was blocking all control repainting. And then unlock too.

How to do it here?
I need it for CudaText, where changing grouping mode makes FLICKER: new groups (child panels) appear, old groups resize...
« Last Edit: December 23, 2018, 05:55:39 pm by Alextp »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: How to lock/unlock control repainting (to eliminate flicker)?
« Reply #1 on: December 22, 2018, 03:11:49 pm »
Control.Invalidate;
---
Also, the canvas has ClipRect;;

Canvvas.ClipRect := TREct(?,?,?,?); Canvas.Clipping := true;

----
You can assign a clear brush to the background of the parent if you are going to repaint the background yourself.

Also the use of ExcludeClipRect can disallow a rect to not be painted.


There are many ways..

« Last Edit: December 22, 2018, 03:15:39 pm by jamie »
The only true wisdom is knowing you know nothing

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How to lock/unlock control repainting (to eliminate flicker)?
« Reply #2 on: December 22, 2018, 05:28:36 pm »
I'm not really sure but, doesn't TForm's BeginFormUpdate/EndFormUpdate do what you want?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

balazsszekely

  • Guest
Re: How to lock/unlock control repainting (to eliminate flicker)?
« Reply #3 on: December 22, 2018, 05:52:27 pm »
On Delphi I was able to use some WIn32 API (with word "Update"? I dont recall)
which was blocking all control repainting. And then unlock too.
API LockWindowUpdate?
Code: Pascal  [Select][+][-]
  1. LockWindowUpdate(Control.Handle);
  2. try
  3.   //...
  4. finally
  5.   LockWindowUpdate(0);
  6. end;

AlexTP

  • Hero Member
  • *****
  • Posts: 2401
    • UVviewsoft
Re: How to lock/unlock control repainting (to eliminate flicker)?
« Reply #4 on: December 23, 2018, 05:55:03 pm »
Thanks! i used your tip and have fixed it:

Code: Pascal  [Select][+][-]
  1. type
  2.   TFormHack = class(TForm);
  3.  
  4. procedure DoControlLock(Ctl: TWinControl);
  5. begin
  6.   if Application.MainForm<>nil then
  7.     TFormHack(Application.MainForm).BeginFormUpdate;
  8. end;
  9.  
  10. procedure DoControlUnlock(Ctl: TWinControl);
  11. begin
  12.   if Application.MainForm<>nil then
  13.     TFormHack(Application.MainForm).EndFormUpdate;
  14. end;
  15.  
« Last Edit: December 23, 2018, 08:02:55 pm by Alextp »

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: [Solved] How to lock/unlock control repainting (to eliminate flicker)?
« Reply #5 on: December 23, 2018, 07:04:47 pm »
That's not crossplatform. Are you sure the invalidate and begin/endupdate things weren't enough? Set form doublebuffering true?
« Last Edit: December 23, 2018, 07:06:54 pm by User137 »

AlexTP

  • Hero Member
  • *****
  • Posts: 2401
    • UVviewsoft
Re: [Solved] How to lock/unlock control repainting (to eliminate flicker)?
« Reply #6 on: December 23, 2018, 08:03:13 pm »
Corrected the code: it is cross platform.

 

TinyPortal © 2005-2018