I wish to use a tpagecontrol as part of a composite component, but am
unable to expose the Pages property. I understand that I need to use a
Getproperty function, but am at a loss as to how this should be written.
protected
{ Protected declarations }
function GetPages:[index : Integer]: TTabSheet;
public
{ Public declarations }
property Pages: TTabSheet read GetPages;
function TTestSubComponent.GetPages:[index : Integer]: TTabSheet;
begin
Result := pgc1.Pages[index];
end;
Does anyone have any help? I am currently using Delphi 6 if that is
important, and attempting to use ccpack to design the composite component.
The component I wish to design is a composite combobox and pagecontrol.
The general idea is not to display tabs on the pages, and use the
combobox as a tab switcher. T
If anyone has any ideas I would welcome them.
thanks
Mal
interface
...........
protected
function GetPages(Index : Integer): TTabSheet;
public
property Pages[Index:integer]: TTabSheet read GetPages;
...........
implementation
...........
function TTestSubComponent.GetPages(index : Integer): TTabSheet;
begin
Result := pgc1.Pages[index];
end;
...........
end.
You coold have found the problem in your definition if you would have
taken the time to take a closer look on the source code of TPageControl
and how it declares the property pages it self.
Regards
Yannis.
--
Grove giveth and Gates taketh away.
- Bob Metcalfe (inventor of Ethernet) on the trend of hardware
speedups not being able to keep up with software demands
Many thanks Yannis.
Unfortunately I cannot look at the source of TPageControl myself. I only
have the Personal edition of Delphi 6 which doesn't have the source
available.
If I did have it available, I would have certainly looked there before
asking here.
Best regards
Mal
In that case I apologise for my comment and I am glad I could be of
service to you.
Regards
Yannis.
--
Everywhere I go I'm asked if I think the university stifles writers. My
opinion is that they don't stifle enough of them.
- Flannery O'Connor (1925-1964)
> function GetPages:[index : Integer]: TTabSheet;
Use paranthesis instead like a normal function:
function GetPages(index : Integer): TTabSheet;
function TTestSubComponent.GetPages(index : Integer): TTabSheet;
begin
Result := pgc1.Pages[index];
end;
> property Pages: TTabSheet read GetPages;
You need to include the bracketed index parameter:
property Pages[index: Integer]: TTabSheet read GetPages;
Gambit
Yannis,
Thanks for the help here, but I am faced with a problem my limited
Delphi experience cannot solve.
I have the TPageControl as part of a composite component, which seems to
work as required, however the data for Pages is not being saved.
I am using the ExtLib components form designer, which (IMS) uses
Delphi's component streaming functions to save its contents to a file.
Unfortunately, the Pages properties are not being streamed/saved/restored.
It seems that the Pages being declared
public
property Pages[Index:integer]: TTabSheet read GetPages;
sidesteps the streaming, and that only "published" properties are
streamed into the form. Is there a trick that I can employ to help this?
It looks like the ExtLib streaming replicates an older Delphi method, I
have googled and it seems that Delphi up to 6 had the same problem, but
I am unable to find a clue as to how this was solved way back then. Do
you have any ideas?
Thanks for any help.
Mal
How are the pages created (some code if possible). I need to take a
look on extlib before commenting any fearther.
In most cases the default streaming mechanism will save all the
components owned by a component to the stream.
I assume that the pages are created with the form that your composite
component resides in as their owner.
Regards
Yannis.
--
Manuscript: something submitted in haste and returned at leisure.
- Oliver Herford (1863-1935)
>> It looks like the ExtLib streaming replicates an older Delphi method,
>> I have googled and it seems that Delphi up to 6 had the same problem,
>> but I am unable to find a clue as to how this was solved way back
>> then. Do you have any ideas?
>
>
> How are the pages created (some code if possible). I need to take a look
> on extlib before commenting any fearther.
>
> In most cases the default streaming mechanism will save all the
> components owned by a component to the stream.
> I assume that the pages are created with the form that your composite
> component resides in as their owner.
>
Thanks, but I solved it. I read that a composite component using a panel
needs to have the parent as self, but it needed to be AOwner, which
allowed the Delphi streaming to work correctly.
Thanks for the help
Mal