Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tpagecontrol as composite component

9 views
Skip to first unread message

Malcolm Nealon

unread,
Apr 18, 2008, 6:17:10 AM4/18/08
to
Hello all

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

yannis

unread,
Apr 18, 2008, 6:41:54 AM4/18/08
to
Malcolm Nealon formulated on Παρασκευή :

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


Malcolm Nealon

unread,
Apr 18, 2008, 6:58:23 AM4/18/08
to
yannis wrote:
> 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.
>

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

yannis

unread,
Apr 18, 2008, 7:15:10 AM4/18/08
to
Malcolm Nealon has brought this to us :

> yannis wrote:
>> 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.
>>
>
> Many thanks Yannis.
>
> Unfortunately I cannot look at the source of TPageControl myself. I only have
> the Personal edition of Delphi 6.
[snip...]

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)


Remy Lebeau (TeamB)

unread,
Apr 18, 2008, 1:35:06 PM4/18/08
to

"Malcolm Nealon" <non...@idontreply.com> wrote in message
news:48087526$1...@newsgroups.borland.com...

> 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


Malcolm Nealon

unread,
Apr 27, 2008, 4:29:22 AM4/27/08
to

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

yannis

unread,
Apr 30, 2008, 3:40:30 AM4/30/08
to
Malcolm Nealon submitted this idea :


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)


Malcolm Nealon

unread,
May 6, 2008, 2:30:57 PM5/6/08
to
yannis wrote:
> Malcolm Nealon submitted this idea :
>> yannis wrote:
>>> Malcolm Nealon formulated on Παρασκευή :
>>>> Hello all

>> 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

0 new messages