0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder XE4 > TColorBox > TColorの取得 > [Selected]プロパティを使う

0
Last updated at Posted at 2019-02-13
動作環境
C++ Builder XE4

関連

  1. インデックスを取得
  2. インデックスに対応するColors[]の要素を取得

としているが、回りくどい。

Selectedを使う

Selectedを使えばよい。

	Panel1->Color = ColorBox1->Selected;

実装

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)
{
	Panel1->ParentBackground = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	Panel1->Color = ColorBox1->Selected;
}
//---------------------------------------------------------------------------

実行例

起動直後
2019-02-13_17h22_58.png

clOliveを選択しButton1を押下した後
2019-02-13_17h23_18.png

関連

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?