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

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[759] [Controls] StringGrid Fixed Cell을 XP스타일로..
장성호 [nasilso] 8549 읽음    2008-03-18 21:15
StringGrid  Fixed Cell을  TMS의 Grid처럼  XP스타일로 만들려면?



별 대단한 팁이 아니구요
GradientFill 이라는  api를 StringGrid 에 적용해 본것입니다.

그냥 간단히 StringGrid의 OnDrawCell 이벤트 핸들러에서
Cell이 FixedCell이면 GradientFill로 배경을 그리고 string을 textout해준것 뿐입니다.

void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
      int ARow, TRect &Rect, TGridDrawState State)
{
    TStringGrid *sGrid=(TStringGrid *)Sender;
    if(ARowFixedRows || AColFixedCols )
    {
        TRIVERTEX Vert[2];
        GRADIENT_RECT  gRect;
        Vert[0].x         = Rect.left;
        Vert[0].y         = Rect.top;
        Vert[0].Red     = 0xff00;
        Vert[0].Green = 0xff00;
        Vert[0].Blue    = 0xff00;
        Vert[0].Alpha   = 0;

        Vert[1].x          = Rect.right;
        Vert[1].y          = Rect.bottom;
        Vert[1].Red     = 0xab00;
        Vert[1].Green  = 0xab00;
        Vert[1].Blue     = 0xab00;
        Vert[1].Alpha    = 0;

        gRect.UpperLeft = 0;
        gRect.LowerRight = 1;

        GradientFill(sGrid->Canvas->Handle,Vert, 2, &gRect, 1, GRADIENT_FILL_RECT_V);
        sGrid->Canvas->Brush->Style=bsClear;
        Rect=TRect(Rect.left+3,Rect.top+2,Rect.right-2,Rect.bottom-2);
        sGrid->Canvas->TextRect(Rect,Rect.left+3,Rect.top+2,StringGrid1->Cells[ACol][ARow]);
    }
}


TRIVERTEX  에 RGB값만 잘 정해주면 다양한 색상의 gradient가 나올것입니다.

참 GradientFill 함수는 msimg32.dll에 있는데..
CBuilder의 Lib폴더에  msimg32.lib를 프로젝트에 포함시켜주세요

그럼..

+ -

관련 글 리스트
759 [Controls] StringGrid Fixed Cell을 XP스타일로.. 장성호 8549 2008/03/18
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.