From ac169056d0bc68957c77ceece86ba34a9a055d77 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 6 Dec 2018 10:56:05 +0000 Subject: [PATCH] tvplanit: Avoid scrolling of VpContactGrid in ScrollIntoView when new contact is already visible (issue #34641). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6747 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpcontactgrid.pas | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/components/tvplanit/source/vpcontactgrid.pas b/components/tvplanit/source/vpcontactgrid.pas index c143af934..6b4d57ef8 100644 --- a/components/tvplanit/source/vpcontactgrid.pas +++ b/components/tvplanit/source/vpcontactgrid.pas @@ -175,6 +175,7 @@ type procedure cgCalcRowHeight; procedure cgEditInPlace(Sender: TObject); procedure cgHookUp; + function ContactIsVisible(AIndex: Integer): Boolean; procedure Paint; override; procedure Loaded; override; procedure cgScrollHorizontal(Rows: Integer); @@ -681,6 +682,14 @@ begin end; {=====} +function TVpContactGrid.ContactIsVisible(AIndex: Integer): Boolean; +var + rec: TVpContactRec; +begin + rec := cgContactArray[AIndex]; + Result := (rec.WholeRect.Left >= 0) and (rec.WholeRect.Right <= ClientWidth); +end; + procedure TVpContactGrid.Loaded; begin inherited; @@ -790,6 +799,9 @@ end; procedure TVpContactGrid.ScrollIntoView; begin + if ContactIsVisible(FContactIndex) then + exit; + if FContactIndex < FContactsBefore then begin FContactsBefore := FContactIndex; Invalidate; @@ -1470,8 +1482,7 @@ end; procedure TVpContactGrid.InitializeDefaultPopup; var - NewItem : TMenuItem; - + NewItem: TMenuItem; begin if RSContactPopupAdd <> '' then begin NewItem := TMenuItem.Create(Self);