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
[40154] 프로그램 실행 시에 Paint 수행에 문제가 있어요
김명구 [cycross] 732 읽음    2005-05-13 10:38
빌더를 사용한지 얼마 안되는 초보자입니다.

프로그램을 실행하고 메뉴에서 해당 폼을 실행하면 폼에 있는 버튼들에 색을 입히는 프로그램을 만들고 있습니다.
폼이 호출되면 버튼에 색을 칠하는 루틴을 FormPaint에 코딩해주고 실행시켰는데 버튼색이 주어진 색으로 안바뀌고 그대로네요 무슨 문제가 있는 것인지......

관련된 소스를 올립니다.
========================================================
void __fastcall TfrmWatch::u_BtnStyle(TButton* Button, AnsiString* Title, TColor color)
{
    tagSIZE btnTag;
    int txtWidth, txtHeight;

    TCanvas *btncan = new TCanvas();

    btncan->Handle = GetDC(Button->Handle);
    btncan->Brush->Style = bsSolid;
    btncan->Brush->Color = color;
    btncan->Pen->Color = clWhite;
    btncan->Font->Color = clWhite;
    btncan->Font->Size = -btncan->Font->Height * 100 / btncan->Font->PixelsPerInch;
    btncan->Rectangle(Button->ClientRect);
    txtWidth = btncan->TextWidth(Title[1]);
    txtHeight = btncan->TextHeight(Title[1]);
    btncan->TextOutA(Button->Width/2 - txtWidth/2,
                                 Button->Height/2 - txtHeight/2, Title[1]);
    ReleaseDC(Button->Handle, btncan->Handle);
    delete btncan;
}
//---------------------------------------------------------------------------

void __fastcall TfrmWatch::u_SetBtn()
{
     for( int i=0 ; i < this->ControlCount ; i++ )
     {
       if(this->Controls[i]->ClassNameIs("TGroupBox"))
       {
         TGroupBox * GBox = dynamic_cast<TGroupBox *>(this->Controls[i]);

         for( int j=0 ; j < GBox->ControlCount ; j++)
         {
            if(GBox->Controls[j]->ClassNameIs("TButton"))
            {
               u_BtnStyle(dynamic_cast<TButton *>(GBox->Controls[j]),BTNTITLE, UNTRIP);
            }
         }
       }
     }
}
//---------------------------------------------------------------------------
void __fastcall TfrmWatch::FormPaint(TObject *Sender)
{
        u_SetBtn();
}
//---------------------------------------------------------------------------

+ -

관련 글 리스트
40154 프로그램 실행 시에 Paint 수행에 문제가 있어요 김명구 732 2005/05/13
40156     Re:프로그램 실행 시에 Paint 수행에 문제가 있어요 수야!╋ 772 2005/05/13
40162         Re:Re:프로그램 실행 시에 Paint 수행에 문제가 있어요 김명구 732 2005/05/13
40164             Re:Re:Re:프로그램 실행 시에 Paint 수행에 문제가 있어요 수야!╋ 855 2005/05/13
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.