Using: TMSSmoothControls v 5.2.3.3 (July 6, 2017) in Delphi Tokyo Pro
My app contains a TFrame that contains a TAdvSmoothPageSlider with *no* pages.
* The frame is created at runtime.
* Initialization logic then creates several TAdvSmoothPage instances inside the TAdvSmoothPageSlider.
This works fine apart from an AV:
~~~~~~~~~~~~~~~~~~~~~~
Project MyApp.exe raised exception class EReadError with message 'Error reading PageSlider.ActivePageIndex: Control 'MyFrame' has no parent window'.
~~~~~~~~~~~~~~~~~~~~~~
The debug stack pins this down to a request for a window handle during the dfm load of the frame processing property ActivePageIndex (which is -1). This occurs in the Create() so there is no chance to assign Parent.
My solution is:
unit AdvSmoothPageSlider.pas
1) Add "default -1" to property ActivePageIndex (Line 342)
TAdvSmoothPageSlider = class(TAdvSmoothPage, ITMSStyle, ITMSTones)
...
published
...
property ActivePageIndex: Integer read GetActivePageIndex write SetActivePageIndex default -1;
This avoids unnecessary setter logic being fired.
AND
2) Avoid GetPageRect() call if there are no pages (circa Line 2153):
procedure TAdvSmoothPageSlider.SetAllPagesPosition;
var
i: Integer;
R: TRect;
APage: TAdvSmoothPage;
begin
if FPages.Count > 0 then //<<< ADDED
R := GetPageRect;
This works for me - although may not be best solution. :-)
Footnote: Due to custom application settings, it is not practical to build the TAdvSmoothPageSlider and pages at design time.
While we are at it, is it possible to add more defaults to published properties to reduce the bloat in dfms? (HeaderFill, FooterFill, ... etc.) Ideally, the dfm should only include overridden properties.
Thanks, Ian