ryan_sabarre
asked on
Coloring TPageControl TabSheets
I want to change the color of the TAB whenever that current tab is selected and when you select another tab then the color will be back to normal.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry but your example will not work I'VE USEd the TPageControl with TTabSheet
with delphi 3.0
with delphi 3.0
hum, i used d7
ASKER
I will received an undeclared identifying:'Canvas'
Hi,
Delphi provides the PageControle with a HotTrack-property, which colors the text of the Tabsheet Blue if the mousepointer is over the tabsheet.
This is implemented in Delphi5. Not sure if it was also provided in version 3.
Maybe this is enough to solve your problem ?
Delphi provides the PageControle with a HotTrack-property, which colors the text of the Tabsheet Blue if the mousepointer is over the tabsheet.
This is implemented in Delphi5. Not sure if it was also provided in version 3.
Maybe this is enough to solve your problem ?
well, don't know if the TPageControl provides a canvas at d3
maybe this change helps
//property OwnerDraw must be set to true
procedure TForm1.PageControl1DrawTab (Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
ARect : TRect;
pc : TPageControl;
begin
if (Control is TPageControl) then
begin
pc := Control as TPageControl;
ARect := Rect;
pc.Canvas.brush.Color := clBtnFace;
pc.Canvas.FillRect(ARect);
InflateRect(ARect,-2,-2);
if active then
pc.Canvas.brush.Color := clRed
else
pc.Canvas.brush.Color := clBtnFace;
pc.Canvas.FillRect(ARect);
pc.Canvas.TextOut(ARect.Le ft+2,ARect .top+2,
pc.Pages[TabIndex].Caption );
end;
end;
hope that helps
meikl ;-)
maybe this change helps
//property OwnerDraw must be set to true
procedure TForm1.PageControl1DrawTab
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
ARect : TRect;
pc : TPageControl;
begin
if (Control is TPageControl) then
begin
pc := Control as TPageControl;
ARect := Rect;
pc.Canvas.brush.Color := clBtnFace;
pc.Canvas.FillRect(ARect);
InflateRect(ARect,-2,-2);
if active then
pc.Canvas.brush.Color := clRed
else
pc.Canvas.brush.Color := clBtnFace;
pc.Canvas.FillRect(ARect);
pc.Canvas.TextOut(ARect.Le
pc.Pages[TabIndex].Caption
end;
end;
hope that helps
meikl ;-)
ASKER
Sorry, ive used hot track but want to have the whole tab to use different color instead.
ASKER
TPageControl do not have a canvas property
ASKER