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
DH
> 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
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
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.
>> (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
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.
DH
>> 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
DH
> 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
ahahahahahahahaha
DH
Ain't you Zarasoustrah ?
> 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
> > > 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
DH