From b58836d2c6e880b7431f186a4515e24544b6a2b8 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 23 Nov 2019 15:50:00 +0000 Subject: [PATCH] jvcllaz: Fix TJvItemViewer "hiding" pages in a PageControl (https://forum.lazarus.freepascal.org/index.php/topic,47499.msg340236.html#msg340236). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7198 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../JvCustomControls/jvcustomitemviewer.pas | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/components/jvcllaz/run/JvCustomControls/jvcustomitemviewer.pas b/components/jvcllaz/run/JvCustomControls/jvcustomitemviewer.pas index a29f06473..007acda7f 100644 --- a/components/jvcllaz/run/JvCustomControls/jvcustomitemviewer.pas +++ b/components/jvcllaz/run/JvCustomControls/jvcustomitemviewer.pas @@ -258,6 +258,8 @@ type procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; + procedure Loaded; override; + //procedure GetDlgCode(var Code: TDlgCodes); override; procedure BoundsChanged; override; //procedure FocusSet(PrevWnd: THandle); override; @@ -888,11 +890,7 @@ begin VertScrollBar.Tracking := Options.Tracking; DoubleBuffered := True; BorderStyle := bsSingle; -// Width := 185; -// Height := 150; TabStop := True; - with GetControlClassDefaultSize do - SetInitialBounds(0, 0, CX, CY); end; destructor TJvCustomItemViewer.Destroy; @@ -949,8 +947,8 @@ end; class function TJvCustomItemViewer.GetControlClassDefaultSize: TSize; begin - Result.CX := 185; - Result.CY := 150; + Result.CX := 200; //185; + Result.CY := 200; //150; end; procedure TJvCustomItemViewer.OptionsChanged; @@ -1576,16 +1574,13 @@ end; procedure TJvCustomItemViewer.SetSelectedIndex(const Value: Integer); begin - // if (FSelectedIndex <> Value) then - begin - if (FSelectedIndex >= 0) and (FSelectedIndex < Count) and (cdsSelected in Items[FSelectedIndex].State) then - Items[FSelectedIndex].State := Items[FSelectedIndex].State - [cdsSelected]; + if (FSelectedIndex >= 0) and (FSelectedIndex < Count) and (cdsSelected in Items[FSelectedIndex].State) then + Items[FSelectedIndex].State := Items[FSelectedIndex].State - [cdsSelected]; - FSelectedIndex := Value; + FSelectedIndex := Value; - if (Value >= 0) and (Value < Count) and not (cdsSelected in Items[Value].State) then - Items[Value].State := Items[Value].State + [cdsSelected]; - end; + if (Value >= 0) and (Value < Count) and not (cdsSelected in Items[Value].State) then + Items[Value].State := Items[Value].State + [cdsSelected]; end; procedure TJvCustomItemViewer.ToggleSelection(Index: Integer; @@ -1666,7 +1661,11 @@ procedure TJvCustomItemViewer.UpdateAll; begin if (csDestroying in ComponentState) or (Parent = nil) then Exit; - HandleNeeded; + + { wp: Don't call HandleNeeded here!. If the viewer is inserted into a + PageControl all following pages will be hidden. } + // HandleNeeded; + if not HandleAllocated then Exit; @@ -1766,6 +1765,13 @@ begin FOnScroll(Self); end; +procedure TJvCustomItemViewer.Loaded; +begin + inherited; + HandleNeeded; + UpdateAll; +end; + procedure TJvCustomItemViewer.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin