Implements loading/saving the state of the pages properly in the form designer for TUntabbedNotebook

git-svn-id: trunk@27142 -
This commit is contained in:
sekelsenmat 2010-08-19 09:29:46 +00:00
parent 44e4879443
commit 230ddb896f
2 changed files with 62 additions and 1 deletions

View File

@ -322,6 +322,8 @@ type
{ TUNBPage }
TUNBPage = class(TCustomControl)
protected
procedure SetParent(AParent: TWinControl); override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -382,10 +384,39 @@ type
// property PageCount: integer read GetPageCount;
// property PageList: TList read FPageList;
published
// property TabStop default true;
// TUntabbedNotebook specific properties
property PageIndex: Integer read GetPageIndex write SetPageIndex default -1;
property Pages: TStrings read FPages;
// property ActivePage: String read GetActivePage write SetActivePage;
// Generic properties
property Align;
property Anchors;
property BorderSpacing;
property Constraints;
property DragCursor;
property DragMode;
property Enabled;
property OnChangeBounds;
// property OnChanging;
property OnContextPopup;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
// property OnPageChanged;
property OnResize;
property OnStartDrag;
// property Options;
// property PageIndex;
property PopupMenu;
property TabOrder;
property TabStop;
end;
{ Timer }

View File

@ -21,6 +21,36 @@
{ TUNBPage }
procedure TUNBPage.SetParent(AParent: TWinControl);
var
OldParent: TWinControl;
ParentNotebook: TUntabbedNotebook;
i: integer;
begin
if (AParent = Parent) {or (pfInserting in FFlags)} then Exit;
OldParent := Parent;
if (OldParent <> AParent) and (OldParent <> nil) and
(OldParent is TUntabbedNotebook) {and (not (pfRemoving in FFlags))} then
begin
// remove from old pagelist
ParentNotebook := TUntabbedNotebook(OldParent);
i := ParentNotebook.FPageList.IndexOf(Self);
ParentNotebook.Pages.Delete(i);
end;
inherited SetParent(AParent);
if (Parent <> nil) and (Parent is TUntabbedNotebook) then
begin
// add to new pagelist
ParentNotebook := TUntabbedNotebook(Parent);
i := ParentNotebook.FPageList.IndexOf(Self);
if i < 0 then
ParentNotebook.InsertPage(Self, ParentNotebook.Pages.Count);
end;
end;
constructor TUNBPage.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);