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

Disable a TAB in a PageControl

1,504 views
Skip to first unread message

sup...@sisinvest.com.br

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
How can i disable a specific TAB of a PageControl?

i tried to use the enable option of the tab, but with no success result.

tks.

Fabiano

Craig Stuntz

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to

sup...@sisinvest.com.br wrote:
>
> How can i disable a specific TAB of a PageControl?

You can hide the tab altogether by setting TabVisible := FALSE. I
don't know if it's possible to disable a tab while keeping it visible;
I've never seen this done anywhere.

-Craig

--
Craig Stuntz Vertex Systems Corporation
Senior Developer http://www.vertexsoftware.com

Delphi/InterBase weblog: http://delphi.weblogs.com

Peter Below (TeamB)

unread,
Nov 21, 2000, 3:00:00 AM11/21/00
to
In article <8ve8ms$cm...@bornews.inprise.com>, wrote:
> How can i disable a specific TAB of a PageControl?

The standard pagecontrol only allows you to hide a tab (Tabvisible =
false), you can disable a tabsheet but the tab is not part of the
tabsheet, it is part of the pagecontrol, so it is still enabled.

If you go to http://www.deja.com, http://www.mers.com/searchsite.html or
http://www.tamaracka.com/search.htm and search the newsgroups for
PBPagecontrol you will find a simple pagecontrol derivative that handles
disabled tabsheets correctly.


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


Tony Lenton

unread,
Nov 22, 2000, 3:00:00 AM11/22/00
to
Thanks Peter, I've also been wanting a Page Control that can disable tabs as
well as hide them. I've taken the liberty of making one modification to
your control which now displays the disabled tab caption in '3D'.
The modification is to the DrawTab method which I've added below. Create a
new dummy project and place the original PBPageControl on the form. Right
click TPBPageControl in the Unit file and select 'Find Declaration' the
PBPageControl unit should load. Make the changes, then goto
'Project-Build Project1'. The control will then display the text in 3D
style when it is used in a project.
To get the change to work in the IDE I had to remove the original
TPBPageControl control from 'dclusr50.dpk' and then reinstall it.

Cheers.................Tony

// Modified procedure
procedure TPBPageControl.DrawTab(TabIndex: Integer; const Rect: TRect;
Active: Boolean);
var
imageindex: Integer;
r, tmpRect: TRect; // tmpRect added
S: String;
begin
If Active then begin
Canvas.Font.Style := [fsBold];
end;

If Assigned( OnDrawTab ) then begin
inherited
end
Else Begin
r:= Rect;
Canvas.Fillrect( r );
imageindex := GetImageIndex( tabindex );

If (imageindex >=0) and Assigned( Images ) Then Begin
SaveDC( canvas.handle );
images.Draw( Canvas, Rect.Left+4, Rect.Top+2,
imageindex,
Pages[TabIndex].enabled );
// images.draw fouls the canvas colors if it draws
// the image disabled, thus the SaveDC/RestoreDC
RestoreDC( canvas.handle, -1 );
R.Left := R.Left + images.Width + 4;
End;

// print caption
S:= Pages[ TabIndex ].Caption;
InflateRect( r, -2, -2 );

// if tab disabled then display text disabled THIS IS THE CHANGED SECTION
// TmpRect added in var section
if not Pages[TabIndex].Enabled then begin
Canvas.Brush.Style := bsClear;
TmpRect := R;
OffsetRect( TmpRect, 1, 1 );
Canvas.Font.Color := clWhite; // shadow
DrawText(Canvas.Handle, PChar(S), Length(S), TmpRect,
DT_SINGLELINE or DT_LEFT or DT_TOP);

OffsetRect( TmpRect, -1, -1);
Canvas.Font.Color := clGray; // main
DrawText(Canvas.Handle, PChar(S), Length(S), TmpRect,
DT_SINGLELINE or DT_LEFT or DT_TOP);
end
else begin // draw text normally
DrawText( Canvas.Handle, PChar(S), Length(S), r,
DT_SINGLELINE or DT_LEFT or DT_TOP );
end;
End;
end;


0 new messages