TabSheet有一个 HighLighted属性,设为ture时,此TAB就高亮显示,但是有的客户比较刁钻,不仅要高亮,还要红色显示,
而PageColor没有此属性,只有手工去画TAB的颜色了。
首先设置 Pagecontrol->OwnerDraw = true ;
在 PageControl 的 OnDrawTab事件里里重画TAB,
void __fastcall TForm1::PageControl1DrawTab(TCustomTabControl *Control,
int TabIndex, const TRect &Rect, bool Active)
{
TTabSheet * ts = PageControl1-> Pages[TabIndex];
TCanvas * can = Control-> Canvas;
if(Active){
can-> Brush-> Color = clRed;
can-> FillRect(Rect);
}
TSize size = can-> TextExtent(ts-> Caption);
int left = (Rect.Width()-size.cx+1)/2;
int top = (Rect.Height()-size.cy+1)/2; // 计算画caption的顶点
can-> Pen-> Color = clWhite;
SetBkMode(can-> Handle,TRANSPARENT);
can-> TextOut(Rect.Left+left,Rect.Top+top,ts-> Caption);
}