Page 1 of 1

TRzPageControl Tab Colors.

PostPosted: Sun Oct 15, 2017 4:39 pm
by SteveG
Hi Ray,

I've never been able to work out how to set the individual colors of tabs. When I read the help in RAD Studio XE7 today (which rarely works), I read this in the section about UseColoredTabs:

The UseColoredTabs property determines whether the color of each tab is derived from the color value for each tab (in the tabs information) or from the color of the control. The default value is False. When False, the color of the tabs will be based on the current Color of the control (which can in turn be determined by the ParentColor value). When True, each tabs color will be the color specified in the tabs information entered via the Edit Tabs editor (accessed via the context menu).

I've never seen the Edit Tabs editor and it certainly doesn't appear in the context menu for me. This probably explains why I've never been able to set the colors.

I have been using XE7 for years, first on one computer and then on a new computer. I wouldn't think it would be an installation problem as I had to newly install Delphi on the new computer and all of the components I use. The Edit Tabs editor has never appeared on either computer.

RAD Studio XE7 Professional
Raize Components Version 6.1.10.

Regards,

Steve

Re: TRzPageControl Tab Colors.

PostPosted: Sun Oct 15, 2017 11:25 pm
by Raize Support
Hi Steve,

I understand the confusion. The TRzPageControl is related to the TRzTabControl and both components share a common architecture and features. However, for colored tabs, setting the colors for each tab are handled differently between the two controls. But let me also add some clarification to what happens when UseColoredTabs is set to False (the default).

When UseColoredTabs is False, each tab is painted using the colors specified in the TabColors property. When UseColoredTabs is True, then the tabs in a TRzTabControl are painted using the Color defined in the Tabs collection for the control. Tabs in a TRzPageControl are painted using the Color of the TabSheet.

Therefore, using different colors for tabs in a TRzPageControl is actually quite simple. First, set the UseColoredTabs property for the TRzPageControl to True. Then for each TRzTabSheet that you add to the TRzPageControl, set the tabsheet's Color property.

Ray

Re: TRzPageControl Tab Colors.

PostPosted: Sun Oct 15, 2017 11:57 pm
by SteveG
Hi Ray,

Raize Support wrote:Hi Steve,

I understand the confusion. The TRzPageControl is related to the TRzTabControl and both components share a common architecture and features. However, for colored tabs, setting the colors for each tab are handled differently between the two controls. But let me also add some clarification to what happens when UseColoredTabs is set to False (the default).

When UseColoredTabs is False, each tab is painted using the colors specified in the TabColors property. When UseColoredTabs is True, then the tabs in a TRzTabControl are painted using the Color defined in the Tabs collection for the control. Tabs in a TRzPageControl are painted using the Color of the TabSheet.

Therefore, using different colors for tabs in a TRzPageControl is actually quite simple. First, set the UseColoredTabs property for the TRzPageControl to True. Then for each TRzTabSheet that you add to the TRzPageControl, set the tabsheet's Color property.

Ray


Ahh, ok. Thanks for that.

It would be nice if at all possible (some time in the future) to be able to set the color of the tabs themselves for the TRzPageControl rather than the whole page.

BTW, I have been using the Konopka Signature VCL Controls in their Raize Components incarnation for years now in all of my projects. They're still the best around!

Regards,

Steve

Re: TRzPageControl Tab Colors.

PostPosted: Mon Oct 16, 2017 12:23 am
by Raize Support
Hi Steve,

You can use the OnPaintTabBackground event to colorize just the tabs yourself. The following sample event handler shows how.

Code: Select all
procedure TForm8.RzPageControl1PaintTabBackground(Sender: TObject; ACanvas: TCanvas; ATabIndex: Integer;
  const ARect: TRect; var Handled: Boolean);
begin
  case ATabIndex of
    0: ACanvas.Brush.Color := clLime;
    1: ACanvas.Brush.Color := clYellow;
    2: ACanvas.Brush.Color := clRed;
  end;
  ACanvas.FillRect( ARect );
  Handled := True;
end;


Thanks for your feedback regarding the components, I appreciate that!

Ray

SteveG wrote:It would be nice if at all possible (some time in the future) to be able to set the color of the tabs themselves for the TRzPageControl rather than the whole page.

BTW, I have been using the Konopka Signature VCL Controls in their Raize Components incarnation for years now in all of my projects. They're still the best around!

Regards,

Steve

Re: TRzPageControl Tab Colors.

PostPosted: Mon Oct 16, 2017 2:13 am
by SteveG
Raize Support wrote:Hi Steve,

You can use the OnPaintTabBackground event to colorize just the tabs yourself. The following sample event handler shows how.

Code: Select all
procedure TForm8.RzPageControl1PaintTabBackground(Sender: TObject; ACanvas: TCanvas; ATabIndex: Integer;
  const ARect: TRect; var Handled: Boolean);
begin
  case ATabIndex of
    0: ACanvas.Brush.Color := clLime;
    1: ACanvas.Brush.Color := clYellow;
    2: ACanvas.Brush.Color := clRed;
  end;
  ACanvas.FillRect( ARect );
  Handled := True;
end;


Thanks for your feedback regarding the components, I appreciate that!

Ray


Awesome, thanks Ray!

Regards,

Steve

Re: TRzPageControl Tab Colors.

PostPosted: Fri Oct 27, 2017 5:32 am
by sarahah
Raize Support wrote:Hi Steve,
Code: Select all
procedure TForm8.RzPageControl1PaintTabBackground(Sender: TObject; ACanvas: TCanvas; ATabIndex: Integer;
  const ARect: TRect; var Handled: Boolean);
begin
  case ATabIndex of
    0: ACanvas.Brush.Color := clLime;
    1: ACanvas.Brush.Color := clYellow;
    2: ACanvas.Brush.Color := clRed;
  end;
  ACanvas.FillRect( ARect );
  Handled := True;
end;


This is helpful to me. Thanks.. :)