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

fontcolor Tabsheet

158 views
Skip to first unread message

lexus

unread,
Dec 16, 1998, 3:00:00 AM12/16/98
to
I have a pagecontrol placed on my form. How can I change the fontcolor
of each individual tabsheet of the pagecontrol ?


Peter Below

unread,
Dec 17, 1998, 3:00:00 AM12/17/98
to
>
> I have a pagecontrol placed on my form. How can I change the fontcolor
> of each individual tabsheet of the pagecontrol ?

Use the OnDrawTab event (requires D4).

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!


Rafael Vargas

unread,
Dec 17, 1998, 3:00:00 AM12/17/98
to
Would you please post an example?
I can't figure what to do...
--
Rafael Vargas
DBA,
Bratex Dominicana C. por A.
ra...@oscarbbs.com

Peter Below <10011...@compuserve.com> wrote in article
<VA.00002379.00e10fee@petersnewbox>...

Peter Below

unread,
Dec 18, 1998, 3:00:00 AM12/18/98
to
> Would you please post an example?
> I can't figure what to do...
> --
Rafael,

here is one:

procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
begin
With Control.Canvas Do Begin
If Active Then
Brush.Color := clBlue
Else
Brush.Color := clSilver;
Brush.Style := bsSolid;
Fillrect( Rect );
If TabIndex >= 0 Then Begin
If Active Then
Font.Color := clWhite
Else
Font.Color := clBlack;
Brush.Style := bsClear;
TextRect( Rect, rect.left+4, rect.top+2,
(Control As TPageControl).Pages[TabIndex].Caption );
End;
End;
end;

Note that the PageControls OwnerDraw property needs to be set to True for
the OnDrawTab event to fire.

Rafael Vargas

unread,
Dec 18, 1998, 3:00:00 AM12/18/98
to
Peter, thanks a lot, I don't know what Delphi would be without you! :)
If I'd want to make a descendant from PageControl to have this behaviour at
design time too, what would I have to do?

--
Rafael Vargas
DBA,
Bratex Dominicana C. por A.
ra...@oscarbbs.com

Peter Below <10011...@compuserve.com> wrote in article

<VA.00002397.004599e9@petersnewbox>...


> > Would you please post an example?
> > I can't figure what to do...
> > --
> Rafael,
>
> here is one:
>
> procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
> TabIndex: Integer; const Rect: TRect; Active: Boolean);

...

Peter Below

unread,
Dec 19, 1998, 3:00:00 AM12/19/98
to
> If I'd want to make a descendant from PageControl to have this behaviour at
> design time too, what would I have to do?
> --
Rafael,

The D4 TPageControl inherits a protected method from TCustomTabControl:

procedure DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean);
virtual;

Your descendent has to override this method and do its drawing there.
TCustomTabControl.DrawTab only fires the OnDrawTab event, so if you want ot
fire the event in addition to your custom drawing you have to call the
inherited DrawTab method from your overriden version. If you do not call the
inherited method the OndrawTab event will never fire.

Rafael Vargas

unread,
Dec 21, 1998, 3:00:00 AM12/21/98
to
Peter,

I was looking at the DrawTab's source. But my Delphi knowledge doesn't
reach that level.

I want to make a descendant from TCustomTabControl, or maybe TWinControl to
behave like TPageControl and include the Ctrl3D Property for the whole
component (the tabs and sheets).

If I make a descendant from TCustomTabControl and override the DrawTab, it
will draw the tabs flat, but the tabsheets (the panel containing the
sheets) won't be flat.

I was checking that TCustomTabControl doesn't have a CMCtrl3DChanged like
TCustomTreeView.

--
Rafael Vargas
DBA,
Bratex Dominicana C. por A.
ra...@oscarbbs.com

Peter Below <10011...@compuserve.com> wrote in article

<VA.000023ac.0129beed@petersnewbox>...

Peter Below

unread,
Jan 4, 1999, 3:00:00 AM1/4/99
to
> I was looking at the DrawTab's source. But my Delphi knowledge doesn't
> reach that level.
>
> I want to make a descendant from TCustomTabControl, or maybe TWinControl to
> behave like TPageControl and include the Ctrl3D Property for the whole
> component (the tabs and sheets).
>
> If I make a descendant from TCustomTabControl and override the DrawTab, it
> will draw the tabs flat, but the tabsheets (the panel containing the
> sheets) won't be flat.
>
> I was checking that TCustomTabControl doesn't have a CMCtrl3DChanged like
> TCustomTreeView.
>
Rafael,

this task is pretty hopeless, i'm afraid. TPageControl is based on a windows
common control and like most of the newer common controls it is designed to
use the 3D style that is the default for the Windows 95 UI. There is no way
to get it to draw without the 3D effect. It should be possible to derive a
new component from TPageControl, add a handler for WM_PAINT or perhaps
WM_NCPAINT to it, call inherited first and then simply paint over what the
control painted. Will probably not be that pleasant visually.

Perhaps you should try to fake something using a TPanel or a stack of TPanels
for the tab sheets plus a TTabControl for the navigation.

Rafael Vargas

unread,
Jan 5, 1999, 3:00:00 AM1/5/99
to
Peter, thanks for everything.
By the time I will give up using non-3D forms, till I have the time to dig
into VCL source...

--
Rafael Vargas
DBA,
Bratex Dominicana C. por A.
ra...@oscarbbs.com

Peter Below <10011...@compuserve.com> wrote in article

<VA.000023f4.012fe6ca@petersnewbox>...

0 new messages