C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[46540] Re:스피드 버튼 그림 바꾸기 질문입니다. - ImageList에서...
장성호 [nasilso] 3295 읽음    2006-09-14 19:07
[방법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);
:
: 어떻게 하면 버튼과 어우러지게 비트맵을 불러올 수 있을까요?

+ -

관련 글 리스트
46539 스피드 버튼 그림 바꾸기 질문입니다. 권기식.with☆ 1106 2006/09/14
46540     Re:스피드 버튼 그림 바꾸기 질문입니다. - ImageList에서... 장성호 3295 2006/09/14
46542         감사합니다. 권기식.with☆ 979 2006/09/15
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.