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를 프로젝트에 포함시켜주세요
그럼..
|