LoginSignup
0
0

More than 5 years have passed since last update.

C++ Builder 10.2 Tokyo > PageControl > タブの色の変更 > 2004年の情報:できない | 別の方法:違和感

Last updated at Posted at 2018-05-18
動作環境
RAD Studio 10.2 Tokyo Update 3
Windows 10 Pro (64bit) バージョン 1803 (April 2018 Update)

希望動作

  • PageControl内のタブの色を変更する

情報1. Delphi実装例 (2004年)

上記を元に以下を実装してみた。

Unit1.cpp
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PageControl1DrawTab(TCustomTabControl *Control, int TabIndex,
          const TRect &Rect, bool Active)
{
    switch(TabIndex) {
    case 0:
        Brush->Color = clAqua;
        break;
    case 1:
        Brush->Color = clLime;
        break;
    default:
        Brush->Color = clGray;
        break;
    }

    if (Active) {
        Brush->Color = clYellow;
    }

    Control->Canvas->FillRect(Rect);
    Control->Canvas->TextOutW(Rect.Left+4, Rect.Top+4, PageControl1->Pages[TabIndex]->Caption);
}
//---------------------------------------------------------------------------

タブの色の変更はできない。

qiita.png

情報2. STACK OVERFLOW (2011年)

How can I change the background color of my TTabSheets?

  • A. styleプロパティを「tsFlatButtons」にする by Johan
  • B. themes.pasを参考にしてFormの色を変える by Peter Turner
    • ThemsesEnabled時はclBtnHighlightにする

下図は方法A(tsFlatButtonsにした場合)の結果。
qiita.png

下図は方法B(clBtnHighlightにした場合)の結果。
qiita.png

A,Bどちらの対応にも違和感を感じる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0