PageControl tab color? lazarus / 31-LCL ---------------------------------------------------------------------- IPguy · 2010-06-27 12:48 I can set the tPageControl tabsheet body color (tTabSheet.color := ...). Is there a property to set the corresponding tab color? Using: Lazarus: 0.9.29 (2010-06-13). ---------------------------------------------------------------------- garlar27 · 2010-07-01 09:55 In Delphi I used to set OwnerDraw Property to True in order to use the TPageControl.OnPaint event. In Lazarus these propertys and events already exist, BUT they are hidden as private or protected so they are unreachable, and I don't know why (maybe due to crossplatform issues). It would be nice to have'em published. ---------------------------------------------------------------------- Przemyslav · 2017-03-08 10:58 I have the same question. I would like to have color tabs on TabSheet. I have code for C++ which works very well: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i void __fastcall TForm1::PageControl1DrawTab(TCustomTabControl *Control,    int TabIndex, const TRect &Rect, bool Active) // kolor zakladek{      try        {                AnsiString z1; TColor f1,f2;              TTabSheet *PTab;                TCanvas *ACanvas;                TRect CRect;                 CRect = Rect;                 PTab = PageControl1->Pages[TabIndex];                ACanvas = Control->Canvas;                z1 = PTab->Caption;                 f1 = clBtnFace; //domyslny kolor zakladek i tekstu                f2 = clWindowText;                 if (Active == true)                {                      f1 = clBtnFace; f2 = clWindowText; // domyslny kolor zakladek i tekstu, jesli aktywna                        switch(TabIndex)                        {                              // poszczegolna definicja kolorow i tekstu dla zakladek                              case 0: f1 = clSkyBlue; f2 = clBlack; break;                              case 1: f1 = clSkyBlue; f2 = clBlack; break;                              case 2: f1 = clSkyBlue; f2 = clBlack; break;                                case 3: f1 = clSkyBlue; f2 = clBlack; break;                                case 4: f1 = clMoneyGreen; f2 = clBlack; break;                                case 5: f1 = clMoneyGreen; f2 = clBlack; break;                              case 6: f1 = clMoneyGreen; f2 = clBlack; break;                              case 7: f1 = clMoneyGreen; f2 = clBlack; break;                              case 8: f1 = clMoneyGreen; f2 = clBlack; break;                              case 9: f1 = clSilver; f2 = clBlack; break;                                case 10: f1 = clSilver; f2 = clBlack; break;                                case 11: f1 = clSilver; f2 = clBlack; break;                                case 12: f1 = clSilver; f2 = clBlack; break;                                case 13: f1 = clCream; f2 = clBlack; break;                        }              }                 ACanvas->Brush->Color = f1;                ACanvas->Font->Color = f2;                 ACanvas->Font->Name = "Segoe UI";                ACanvas->Font->Size = 8;                ACanvas->FillRect(CRect);                DrawText(ACanvas->Handle,z1.c_str(),-1,&CRect,DT_CENTER | DT_VCENTER | DT_SINGLELINE);        }         catch(Exception& e)        {              MessageBox(NULL, e.Message.c_str(), "TForm1::PageControl1DrawTab()", MB_OK | MB_ICONERROR);        }} In Lazarus I tried like this - code I found on the net for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls, StdCtrls, EditBtn, Menus, Buttons, Windows, Types, LCLType, Messages, ShellApi; type   { TForm1 }   TForm1 = class(TForm)    PageControl1: TPageControl;    TabSheet1: TTabSheet;    TabSheet2: TTabSheet;    TabSheet3: TTabSheet;    TabSheet4: TTabSheet;    procedure FormCreate(Sender: TObject);    procedure PageControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin   PageControl1.OwnerDraw:=true;   TabSheet1.Color:= clMoneyGreen;end; Procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;TabIndex: Integer; const Rect: TRect; Active: Boolean);begin  case TabIndex of    0: Control.Canvas.Brush.Color:=clgreen;    1: Control.Canvas.Brush.Color:=clred;    2: Control.Canvas.Brush.Color:=clblue;    3: Control.Canvas.Brush.Color:=clYellow;  end;  Control.Canvas.TextOut(Re ct.left+5,Rect.top+3,PageControl1.Pages[tabindex].Caption);  PageContr ol1.Pages[TabIndex].Brush.Color:=Control.Canvas.Brush.Color;end; end. But it doesn't work. I have error like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit1.pas(21,101) Error: Duplicate identifier "Active"C:\Users\pcisz\AppData\Local\Temp\unit1.pas Could you help me? ---------------------------------------------------------------------- Girlbrush · 2017-03-08 14:14 You can try renaming the Parameter "Active" to something like "aActive" and see if that fixes it (might conflict with the property form.active) ---------------------------------------------------------------------- wp · 2017-03-08 14:28 In mode objfpc it is not allowed that parameters of methods have the same name as properties. Therefore, in Lazarus parameters usually are named with a prepended "A" -- "AActive" instead of "Active". Alternatively you can use mode Delphi where parameters and properties can be named equally. But even after this modification your code will not work in Lazarus due to the widgetset-dependence of the control. In fact, the pagecontrol does not expose a canvas, and its method OnDrawTab has been removed a long time ago. ---------------------------------------------------------------------- Przemyslav · 2017-03-08 21:40 Thanks for information and help ---------------------------------------------------------------------- AlexTP · 2017-03-09 08:27 PageControl's OnDrawTab event removed (it was before). So you need another component. E.g. http://wiki.freepascal.org/ATTabs