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

Crerating "new" control, tutorial anywhere?

7 views
Skip to first unread message

Malcolm Nealon

unread,
Apr 25, 2008, 5:18:26 AM4/25/08
to
Hello all,

I wish to create a new TPageControl replacement. It should work almost
exactly the same as the current TPageControl component, but should look
like it has a combobox above it, with the ActivePpage being selected by
the combobox (runtime)

In design time I simply wish it to look like a pagecontrol with a
combobox above it(or wherever the Align property decides).

Would experience tell you all that I could simply subclass the
TPageControl and intercept the Paint method be sufficient to have a
visibly different TPageControl component or is there a lot more that
needs to be done? Does/can anyone shed some light onto this for me?

Thanks

David HAROUCHE

unread,
Apr 25, 2008, 8:25:10 AM4/25/08
to
What you should do is "Insert" a TComboBox within the TPageControl and
handle the CombobOx.OnChange event, but what you could do is to use a TFrame
and place both components on it !

DH


Marc Rohloff [TeamB]

unread,
Apr 25, 2008, 9:47:42 AM4/25/08
to
On Fri, 25 Apr 2008 11:18:26 +0200, Malcolm Nealon wrote:

> Would experience tell you all that I could simply subclass the
> TPageControl and intercept the Paint method be sufficient to have a
> visibly different TPageControl component or is there a lot more that
> needs to be done? Does/can anyone shed some light onto this for me?

I wouldn't do custom painting; I would just set the TabVisible
propertiy of each tab to false to hide the default UI and then add my
own.


--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Malcolm Nealon

unread,
Apr 25, 2008, 10:52:37 AM4/25/08
to
Marc Rohloff [TeamB] wrote:
> On Fri, 25 Apr 2008 11:18:26 +0200, Malcolm Nealon wrote:
>
>> Would experience tell you all that I could simply subclass the
>> TPageControl and intercept the Paint method be sufficient to have a
>> visibly different TPageControl component or is there a lot more that
>> needs to be done? Does/can anyone shed some light onto this for me?
>
> I wouldn't do custom painting; I would just set the TabVisible
> propertiy of each tab to false to hide the default UI and then add my
> own.
>

Could you offer some code or a pointer to more information? I am really
interested in when the component is in the designer, i.e. I want to show
a pictorial representation of the combobox/pagecontrol in the designer
but have it behave as a standard TPageControl wrt adding pages/saving
contents/streaming info etc.

Thanks

Malcolm Nealon

unread,
Apr 25, 2008, 11:04:20 AM4/25/08
to
David HAROUCHE wrote:
> What you should do is "Insert" a TComboBox within the TPageControl and
> handle the CombobOx.OnChange event,
Could you shed some light on how I accomplish this "inserting" or point
me to more information on this?


but what you could do is to use a TFrame
> and place both components on it !
>
> DH

true, but (showing my ignorance here) wouldn't that introduce a level of
interference? I really want to create a drop in replacement for a
standard TPageControl, wouldn't using a frame and adding both components
(wouldn't I need a parent panel?) introduce a little intricacy? Or am I
obviously missing something basic here?

Imagine a form with a TPageControl and several pages (TTabSheet), I want
to effectively remove that TPageControl and replace it with my own,
without needing to alter any code written (assuming that several
TTabSheets are created dynamically).

Thanks for your time.

David HAROUCHE

unread,
Apr 25, 2008, 11:18:55 AM4/25/08
to
>> Could you shed some light on how I accomplish this "inserting" or point
You mean source code or links to "how to ..." ?

>> (wouldn't I need a parent panel?) introduce a little intricacy? Or am I

You won't need it using a TFrame ! That's considered by Delphi as a single
component container that owns more than one control !

>> remove that TPageControl and replace it with my own,

The only thing to change, when using a TFrame, will surely be the qualified
name of any instance :

'PageControl99.propertyA' becomes 'MyFrame99.PageControl.propertyA'

In the DFM, I'm not sure - I personaly avoid using TForm visually for my
portable code, because I consider it as a Samples Designer, while the
components should be manually written - but I think that only changing the
type of the class will suits (TPageControl -> TMyFrame)

DH


Malcolm Nealon

unread,
Apr 25, 2008, 11:58:38 AM4/25/08
to
David HAROUCHE wrote:
>>> Could you shed some light on how I accomplish this "inserting" or point
> You mean source code or links to "how to ..." ?

either, source code would be a quick fix, whereas a "how to" would
probably be more beneficial in the long run.


>>> (wouldn't I need a parent panel?) introduce a little intricacy? Or am I
> You won't need it using a TFrame ! That's considered by Delphi as a single
> component container that owns more than one control !

I see,

>
>>> remove that TPageControl and replace it with my own,
> The only thing to change, when using a TFrame, will surely be the qualified
> name of any instance :
>
> 'PageControl99.propertyA' becomes 'MyFrame99.PageControl.propertyA'

and I would have to make sure that any and all properties were revealed
to the outside world, or is there a trick to accomplishing this easily?

>
> In the DFM, I'm not sure - I personaly avoid using TForm visually for my
> portable code, because I consider it as a Samples Designer, while the
> components should be manually written - but I think that only changing the
> type of the class will suits (TPageControl -> TMyFrame)
>

This is what I want to achieve, although your comment above
"'PageControl99.propertyA' becomes 'MyFrame99.PageControl.propertyA'"
seems to indicate that I cannot simply drop my new component onto a form
and have it compile correctly afterwards (assuming names captions
properties remain the same) without needing to change the source.

David HAROUCHE

unread,
Apr 25, 2008, 2:53:31 PM4/25/08
to
CrERATING (create by error) or Creating (simply create) ?

DH


David HAROUCHE

unread,
Apr 25, 2008, 2:49:04 PM4/25/08
to
>>either, source code would be a quick fix, whereas a "how to" would
Just Google for "Delphi TFrame "...

>> This is what I want to achieve,

Here we are...

>> properties remain the same) without needing to change the source.

You could use a trick like this one :

type TMyFrame = class(TFrame)
_pagecontrol:TPageControl;
_combobox:TCombobox;

// declare your create and free methods, as the assign functions
// so that they create, free and assign
// _pagecontrol and _combobox
function GetComboItemIndex:Integer;

procedure SetComboItemIndex(const _value:Integer);

published

PageControl:TPageControl read _pagecontrol write
_pagecontrol;
Combo:TCombobox read _combobox write
_combobox;;

// here you can declare properties linked by Get/Set methods
// to the properties of _pagecontrol and/or _combobox

ItemIndex:Integer read GetComboItemIndex write
SetComboItemIndex;
//
// and so on....with all properties you will use (take care for
duplicate names)
//
end;

You now can change the base class of your TPageControl to TMyFrame, and the
call to the properties will remains the same - you can also do the same for
methods.

What you will not be able to do is to reffer to the property Name without
writing 2 properties called ComboName and PageName !

DH


Malcolm Nealon

unread,
Apr 25, 2008, 5:18:51 PM4/25/08
to
David HAROUCHE wrote:
> CrERATING (create by error) or Creating (simply create) ?
>
> DH
>
>
Creating

David HAROUCHE

unread,
Apr 25, 2008, 7:12:19 PM4/25/08
to
Dangerous (Michael Jackson)

DH


Pieter Zijlstra

unread,
Apr 25, 2008, 7:51:01 PM4/25/08
to
David HAROUCHE wrote:

> Dangerous (Michael Jackson)

Music "discussions" should go in BPOT (b.p.off-topic)

But OTOH, don't go there, it's a dangerous place :)

--
Pieter

David HAROUCHE

unread,
Apr 25, 2008, 8:04:40 PM4/25/08
to
....silence.....

ahahahahahahahaha

DH
Ain't you Zarasoustrah ?


Pieter Zijlstra

unread,
Apr 25, 2008, 8:03:00 PM4/25/08
to
David HAROUCHE wrote:

> Ain't you Zarasoustrah?

?
Googling... no match... what/who is that?

So for the moment it is safe to say, no I'm not <g>


--
Pieter

David HAROUCHE

unread,
Apr 25, 2008, 8:21:00 PM4/25/08
to

Pieter Zijlstra

unread,
Apr 25, 2008, 8:19:39 PM4/25/08
to
David HAROUCHE wrote:

> > > Ain't you Zarasoustrah?

> > Googling... no match... what/who is that?


> > So for the moment it is safe to say, no I'm not <g>

> http://en.wikipedia.org/wiki/Also_sprach_Zarathustra_(Strauss)
>

Nah, this guy is that dead, I'm pretty sure I'm not ;-)

--
Pieter

David HAROUCHE

unread,
Apr 25, 2008, 8:30:02 PM4/25/08
to
Glad to know I do talk with living people ....lol

DH


0 new messages