From 3f96acc7015d54ff9bc80f2298557aec72b86f57 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sun, 19 Feb 2023 12:30:17 +0000 Subject: [PATCH] tvplanit: Clear TVpMonthView's event array before painting. See https://forum.lazarus.freepascal.org/index.php/topic,62366.msg471573.html git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8713 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpmisc.pas | 2 +- components/tvplanit/source/vpmonthview.pas | 9 +++++++++ components/tvplanit/source/vpmonthviewpainter.pas | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index c78ca0ff7..106d89d94 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -207,7 +207,7 @@ procedure LoadImageFromRCDATA(AImage: TImage; ABaseResName: String; function GetScrollbarHeight: Integer; function GetScrollbarWidth: Integer; -procedure FixLabels(AForm: TCustomForm); +procedure FixLabels({%H-}AForm: TCustomForm); procedure Unused(const A1); overload; procedure Unused(const A1, A2); overload; diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index c5dde7571..8d1a7609f 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -278,6 +278,7 @@ type procedure PaintToCanvas(ACanvas: TCanvas; ARect: TRect; Angle: TVpRotationAngle; ADate: TDateTime); } + procedure ClearEventArray; procedure RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect; Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime; StartLine, StopLine: Integer; UseGran: TVpGranularity; @@ -606,6 +607,14 @@ begin Result := descrStr; end; +procedure TVpMonthView.ClearEventArray; +var + I: Integer; +begin + for I := 0 to High(mvEventArray) do + mvEventArray[I] := Default(TVpEventRec); +end; + procedure TVpMonthView.LoadLanguage; var item: TMenuItem; diff --git a/components/tvplanit/source/vpmonthviewpainter.pas b/components/tvplanit/source/vpmonthviewpainter.pas index 3cb0bd1ae..1963121ec 100644 --- a/components/tvplanit/source/vpmonthviewpainter.pas +++ b/components/tvplanit/source/vpmonthviewpainter.pas @@ -88,6 +88,7 @@ procedure TVpMonthViewPainter.Clear; begin RenderCanvas.Brush.Color := RealColor; RenderCanvas.FillRect(RenderIn); + FMonthView.ClearEventArray; end; procedure TVpMonthViewPainter.DrawBorders; @@ -579,9 +580,9 @@ begin { Store TextRect and Event in EventArray } with TVpMonthViewOpener(FMonthView) do begin + mvEventArray[visibleEvents].Rec := TextRect; + mvEventArray[visibleEvents].Event := TVpEvent(EventList.List^[j]); Inc(visibleEvents); - mvEventArray[visibleEvents - 1].Rec := TextRect; - mvEventArray[visibleEvents - 1].Event := TVpEvent(EventList.List^[j]); end; { Move TextRect down one line for the next item... } @@ -807,7 +808,7 @@ begin try SelectClipRgn(RenderCanvas.Handle, Rgn); - { clear client area } + { clear client area and event array } Clear; { measure the row heights }