Use the OnDrawTab event (requires D4).
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!
Peter Below <10011...@compuserve.com> wrote in article
<VA.00002379.00e10fee@petersnewbox>...
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.
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);
...
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.
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>...
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.
Peter Below <10011...@compuserve.com> wrote in article
<VA.000023f4.012fe6ca@petersnewbox>...