<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TabControl und Farbe]]></title><description><![CDATA[<p>Wie kann ich die Fabe der Lasche eines Tabcontrols aendern?<br />
Mir ist klar das das nur ueber das OnDrawTab Ereignis geht.<br />
Allerdings weiss ich nicht wie.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/98188/tabcontrol-und-farbe</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 04:33:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/98188.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Jan 2005 12:33:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TabControl und Farbe on Mon, 17 Jan 2005 12:33:44 GMT]]></title><description><![CDATA[<p>Wie kann ich die Fabe der Lasche eines Tabcontrols aendern?<br />
Mir ist klar das das nur ueber das OnDrawTab Ereignis geht.<br />
Allerdings weiss ich nicht wie.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698723</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698723</guid><dc:creator><![CDATA[Darkfalcon]]></dc:creator><pubDate>Mon, 17 Jan 2005 12:33:44 GMT</pubDate></item><item><title><![CDATA[Reply to TabControl und Farbe on Mon, 17 Jan 2005 12:58:31 GMT]]></title><description><![CDATA[<p>Vielleicht sollte ich noch anfuegen das, wenn ich OwnerDraw auf true setze die Laschen automatisch die Farbe des Tabs annehmen.<br />
Allerdings ist dann schreiben nicht mehr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698757</guid><dc:creator><![CDATA[Darkfalcon]]></dc:creator><pubDate>Mon, 17 Jan 2005 12:58:31 GMT</pubDate></item><item><title><![CDATA[Reply to TabControl und Farbe on Tue, 18 Jan 2005 18:12:10 GMT]]></title><description><![CDATA[<p>Fuer ein PageControl habe ich ein DEMO.<br />
Dazu hab ich ne Komponente von TPageControl abgeleitet:</p>
<pre><code class="language-cpp">//HEADER- DATEI

class TColorPageControl : public TPageControl
{
__published:	// Von der IDE verwaltete Komponenten
private:	// Anwenderdeklarationen
  virtual void __fastcall ShowControl(Controls::TControl* AControl);

  TColor FPageColor;
  TColor FTabColor;
  TColor FTabSheetColor;
  TColor FTabSheetBorderColor;
  virtual void __fastcall CreateParams(Controls::TCreateParams &amp;Params);
  virtual void __fastcall PaintWindow(HDC DC);
  virtual void __fastcall DrawTab(int TabIndex, const Windows::TRect &amp;Rect, bool Active);

  void __fastcall SetPageColor(TColor C);
  void __fastcall SetTabColor(TColor C);
  void __fastcall SetTabSheetColor(TColor C);
  void __fastcall SetTabSheetBorderColor(TColor C);
public:		// Anwenderdeklarationen
        __fastcall TColorPageControl(TComponent* Owner);
__published:
  __property TColor PageColor ={read=FPageColor, write=SetPageColor};
  __property TColor TabColor ={read=FTabColor, write=SetTabColor};
  __property TColor TabSheetColor ={read=FTabSheetColor, write=SetTabSheetColor};
  __property TColor TabSheetBorderColor ={read=FTabSheetBorderColor, write=SetTabSheetBorderColor};
};
//---------------------------------------------------------------------------

//CPP- DATEI

void __fastcall TColorPageControl::ShowControl(Controls::TControl* AControl)
{
  TPageControl::ShowControl(AControl);
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::SetPageColor(TColor C)
{
  FPageColor=C;
  Color=C;
  SetTabSheetBorderColor(C);
//  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::SetTabColor(TColor C)
{
  FTabColor=C;
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::SetTabSheetColor(TColor C)
{
  FTabSheetColor=C;
  Brush-&gt;Color=C;
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::SetTabSheetBorderColor(TColor C)
{
  FTabSheetBorderColor=C;
  Invalidate();
}
//---------------------------------------------------------------------------
__fastcall TColorPageControl::TColorPageControl(TComponent* Owner)
        : TPageControl(Owner)
{
  FPageColor=clBtnFace;
  FTabColor=clBtnFace;
  FTabSheetColor=clBtnFace;
  Color=FTabSheetColor;
  Brush-&gt;Color=FPageColor;
  Canvas-&gt;Brush-&gt;Color=FTabColor;
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::CreateParams(Controls::TCreateParams &amp;Params)
{
  HBRUSH BR;
  TCustomTabControl::CreateParams(Params);
/*
  BR=Params.WindowClass.hbrBackground;
  DeleteObject(BR);
  BR=GetStockObject(HOLLOW_BRUSH);
  Params.WindowClass.hbrBackground=BR;
*/
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::PaintWindow(HDC DC)
{
  TRect R;
  R=DisplayRect;
  R.Left-=4;
  R.Top-=4;
  R.Right+=4;
  R.Bottom+=4;
  TCanvas *CV=new TCanvas;
  CV-&gt;Handle=DC;
  CV-&gt;Brush-&gt;Color=FTabSheetBorderColor;
  CV-&gt;FillRect(R);
  delete CV;
  if (OwnerDraw)
  {
    TPageControl::PaintWindow(DC);
  }
  else
  {
    TPageControl::PaintWindow(DC);
  }
}
//---------------------------------------------------------------------------
void __fastcall TColorPageControl::DrawTab(int TabIndex, const Windows::TRect &amp;Rect, bool Active)
{
  //TPageControl::DrawTab(TabIndex,Rect,Active);
  Canvas-&gt;Brush-&gt;Color=FTabColor;
//  Canvas-&gt;FillRect(Rect);
  Canvas-&gt;TextRect(Rect,
                Rect.Left+(Rect.Width()-Canvas-&gt;TextWidth(Pages[TabIndex]-&gt;Caption)) / 2,
                Rect.Top+(Rect.Height()-Canvas-&gt;TextHeight(Pages[TabIndex]-&gt;Caption)) / 2,
                Pages[TabIndex]-&gt;Caption);
}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TTabSheet *TS;
  CPC=new TColorPageControl(this);
  CPC-&gt;Parent=this;
  TS=new TTabSheet(CPC);
  TS-&gt;PageControl=CPC;
  TS-&gt;Caption=&quot;T1&quot;;
  TS=new TTabSheet(CPC);
  TS-&gt;PageControl=CPC;
  TS-&gt;Caption=&quot;T2&quot;;
  TS=new TTabSheet(CPC);
  TS-&gt;PageControl=CPC;
  TS-&gt;Caption=&quot;T3&quot;;
  CPC-&gt;Left=50;
  CPC-&gt;Top=50;
  CPC-&gt;HotTrack=true;

  CPC-&gt;PageColor=clYellow;
  CPC-&gt;TabColor=clRed;
  CPC-&gt;TabSheetColor=clBlue;
  CPC-&gt;TabSheetBorderColor=clGreen;
  CPC-&gt;OwnerDraw=OD-&gt;Checked;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  delete CPC;
}
//---------------------------------------------------------------------------
</code></pre>
<p>Vielleicht hilft das etwas. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/698914</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698914</guid><dc:creator><![CDATA[DerAltenburger]]></dc:creator><pubDate>Tue, 18 Jan 2005 18:12:10 GMT</pubDate></item><item><title><![CDATA[Reply to TabControl und Farbe on Mon, 17 Jan 2005 20:42:34 GMT]]></title><description><![CDATA[<p>Ich werde mich mal durchbeissen.<br />
Danke fuer deine Antwort.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698921</guid><dc:creator><![CDATA[Darkfalcon]]></dc:creator><pubDate>Mon, 17 Jan 2005 20:42:34 GMT</pubDate></item><item><title><![CDATA[Reply to TabControl und Farbe on Thu, 26 Apr 2007 11:15:03 GMT]]></title><description><![CDATA[<p>So habe ich es gelöst (PrgFarbe ist ein Integerwert für den Hintergrund z.B. clBtnFace):</p>
<pre><code class="language-cpp">void __fastcall TForm1::frm1_tabReiterDrawTab(TCustomTabControl *Control, int TabIndex, const TRect &amp;ARect, bool Active)
{try {                                                                          // Fehlerroutine Start
 AnsiString z1; TColor f1,f2;                                                   // Vars definieren
 TTabSheet *PTab;                                                               // TabControl anlegen
 TCanvas *ACanvas;                                                              // Canvas vorbereiten
 TRect CRect;                                                                   // Rect vorbereiten

 CRect=ARect;                                                                   // Akt. Rect übergeben

 PTab   =frm1_tabReiter-&gt;Pages[TabIndex];                                       // Reiter als Control übergeben
 ACanvas=Control-&gt;Canvas;                                                       // Canvas übergeben
 z1     =PTab-&gt;Caption;                                                         // Text im Reiter

 f1=PrgFarbe;                                                                   // HG Farbe Standard
 f2=clBtnText;                                                                  // VG Farbe Standard

 if(Active==true) {                                                             // REITER IST AKTIV
  f1=clBtnHighlight; f2=clBlack;                                                // Voreinstellung
  switch(TabIndex) {                                                            // welcher Reiter?
  case 1: f1=clGreen;   f2=clWhite;       break;                                // PLAN
  case 2: f1=clMaroon;  f2=clWhite;       break;                                // SCHRANK
  case 3: f1=clNavy;    f2=clWhite;       break;                                // AUFTRÄGE
  case 4: f1=clYellow;  f2=clBlack;       break;                                // BEMERKUNG
  case 5: f1=clFuchsia; f2=clBlack;       break;                                // ZUSTÄNDIG
  case 6: f1=clOlive;   f2=clWhite;       break;                                // ZUBEHÖR
  case 7: f1=clGray;    f2=clWhite;       break;                                // HISTORIE
  case 8: f1=clRed;     f2=clWhite;       break;                                // DATEIEN
  }                                                                             // ende switch(TabIndex
 }                                                                              // ende if(Active

 ACanvas-&gt;Brush-&gt;Color=f1;                                                      // Farbe HG festlegen
 ACanvas-&gt;Font-&gt;Color =f2;                                                      // Farbe VG festlegen

 ACanvas-&gt;Font-&gt;Name=&quot;Arial&quot;; ACanvas-&gt;Font-&gt;Size=8;                            // Schrift anpassen
 ACanvas-&gt;FillRect(CRect);                                                      // Fläche erst füllen
 DrawText(ACanvas-&gt;Handle,z1.c_str(),-1,&amp;CRect,DT_CENTER | DT_VCENTER | DT_SINGLELINE); // Text schreiben

 } catch(Exception&amp; e) { MessageBox(NULL, e.Message.c_str(), &quot;TForm1::frm1_tabReiterDrawTab()&quot;, MB_OK); }  // Fehler anzeigen
}
</code></pre>
<p>Gruss Stefan</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1273850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1273850</guid><dc:creator><![CDATA[Stefan71242]]></dc:creator><pubDate>Thu, 26 Apr 2007 11:15:03 GMT</pubDate></item></channel></rss>