Lazarus

Programming => LCL => Topic started by: RAW on May 25, 2019, 11:26:39 pm

Title: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: RAW on May 25, 2019, 11:26:39 pm
This morning I downloaded a component (TCalendarLite 0.3.4) and wanted to start playing around with it, but with a classic theme it's impossible because of too much flickering.

W7 SP1 x64: DoubleBuffered:= True has no effect.
XP  SP3 x86: DoubleBuffered:= True has no effect, but looks a bit better // not much though ...

- Clicking on the Month/Year buttons is OK.
- Using VK_PRIOR or VK_NEXT is OK too.

Can anybody confirm this ... Anybody who uses a classic theme ?


I did almost nothing ...
Code: Pascal  [Select]
  1. Procedure TwndGUI.FormCreate(Sender: TObject);
  2. Begin
  3.   DoubleBuffered:= True; // classic theme
  4.   BorderStyle   := bsNone;
  5.   Color         := clBlack;
  6.   SetBounds     ((Screen.WorkAreaWidth -1280) Div 2,
  7.                  (Screen.WorkAreaHeight- 768) Div 2,
  8.                  1280, 768);
  9.  
  10.  
  11.   CAL                         := TCalendarLite.Create(Self);
  12.   CAL.SetBounds               (0, 0, Width, Height);
  13.   CAL.DoubleBuffered          := True; // classic theme
  14.   CAL.StartingDayOfWeek       := dowMonday;
  15.   CAL.Colors.BackgroundColor  := clBlack;
  16.   CAL.Colors.SelectedDateColor:= RGBToColor(0, 80, 255);
  17.   CAL.Font.Size               := 20;
  18.   CAL.Font.Quality            := fqAntialiased;
  19.   CAL.Parent                  := Self;
  20. End;
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: jamie on May 26, 2019, 12:09:05 am
I don't know the component but you can try this..

CAL.Brush.Style := bsClear;

That should take care of the WM_EREASEBK message..

Or I guess you could trap that message !
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: RAW on May 26, 2019, 01:17:00 am
Thanks for the info ...

Code: Pascal  [Select]
  1. CAL.Brush.Style := bsClear;
This seems to have no effect ...

Quote
Or I guess you could trap that message !
Like this or directly inside that component?
Code: Pascal  [Select]
  1. // Procedure WndProc (Var MSG: TMessage); Override;
  2.  
  3. Procedure TwndGUI.WndProc(Var MSG: TMessage);
  4. Begin
  5.   If MSG.MSG = WM_ERASEBKGND
  6.   Then MSG.Result:= 1
  7.   Else Inherited WndProc(MSG);
  8. End;
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: jamie on May 26, 2019, 03:30:54 am
You can try it.

Its also possible the control is doing it itself..

But the WM_EraseBk is a very common way to reduce the flicker..
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: wp on May 26, 2019, 03:09:08 pm
This will not work. The component uses too many background erasing steps internally.

Please try the new version in ccr trunk which paints into a bitmap buffer first. In order to update your current installation I think it is enough to copy https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/callite/source/calendarlite.pas over the existing file.
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: RAW on May 26, 2019, 09:32:18 pm
@wp
Thanks, I cannot see any flicker anymore! Yeah, the SVN button and DOWNLOAD SNAPSHOT button ... I should have known ...  :)
// svn://svn.code.sf.net/p/lazarus-ccr/svn/components/callite/
This link didn't work for me, so I thought I use the 0.3.4 stable version ... This PC has no SVN software installed...

Is it possible that FBUFFER isn't freed ?
I get an Error about 11 unfreed Blocks, I'll take a look! Thanks again.

Edit: Looks like this is missing
Code: Pascal  [Select]
  1. destructor TCalDrawer.Destroy;
  2. begin
  3.   FBuffer.Free;
  4.   inherited Destroy;
  5. end;
Title: Re: TCalendarLite - DoubleBuffered - Classic Theme: Doesn't work at all ?!
Post by: wp on May 26, 2019, 10:14:23 pm
Sorry for insufficient testing... The new commit fixes the memory leak. The link to the download of calendarlite.pas is ok: after opening the link you see the sourcecode of this unit - when you click on "Download this file" you get the pas file directly, just copy it over the original one of the 0.3.4 stable release.