|
[방법1] ImageList를 쓰지 않고..
아래와 같이 TBitmap *을 두개 선언해 놓구 사용하니까
Transparent 가 잘 먹히네요
Graphics::TBitmap *icon1,*icon2;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
icon1=new Graphics::TBitmap();
icon2=new Graphics::TBitmap();
icon1->LoadFromFile("C:\\3D.bmp");
icon2->LoadFromFile("C:\\gas.bmp");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
if(SpeedButton2->Tag) {
SpeedButton2->Glyph->Assign(icon1);
SpeedButton2->Tag=0;
}
else {
SpeedButton2->Glyph->Assign(icon2);
SpeedButton2->Tag=1;
}
}
[방법2] ImageList를 쓰고
TBitmap * 에 보면 TransparentColor 와 TransparentMode 가 있습니다
정확히는 모르겠지만 ImageList에 들어간 이미지는 Transparent관련 설정이 ImageList설정을 따르는것 같습니다
ImageList에 bitmap을 추가할때 TransparentColor 를 설정할수 있지만
TImageList *의 BkColor를 BkColor = clNone 로 되어있으니까
Transparent가 먹히지 않더군요
그래서 TImageList *의 BkColor =clWhite로 설정해 주었습니다.
그러니 Transparent가 잘 먹히는 군요
그럼 즐플...
권기식.with☆ 님이 쓰신 글 :
: 아래와 같이 스피드 버튼을 누를 때마다 그림을 토글 시키려고 합니다.
: TImageList를 이용했구요...
:
: void __fastcall TForm3::SpeedButton1Click(TObject *Sender)
: {
: Graphics::TBitmap *icon = new Graphics::TBitmap();
:
: if(SpeedButton1->Down) {
: ImageList->GetBitmap(0, icon);
: SpeedButton1->Glyph = icon;
: }
: else {
: ImageList->GetBitmap(1, icon);
: SpeedButton1->Glyph = icon;
: }
:
: delete icon;
: }
:
: 토글은 잘 되는데...
: 이미지의 배경색이 하얗게 나와버려서 보기가 싫어요.
: Glyph 속성에서 바로 파일을 불러오면 배경이 투명하게 잘 불러지는데...
:
: 아래와 같이 하니 최초 한 번만 적용되고 그 후에는 적용이 안되네요.
:
: ImageList->GetBitmap(0, SpeedButton1->Glyph);
:
: 어떻게 하면 버튼과 어우러지게 비트맵을 불러올 수 있을까요?
|