请问该怎么设置,如果要是人工画该怎么画??
7 个解决方案
#1
把ownerDraw设为True,在OnDrawTab中写
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var l_cap :String;
l_rect:Trect;
begin
if TabIndex=PageControl1.TabIndex then
begin
with PageControl1.Canvas do
begin
// Font.Color := clBlue;
Brush.Color := clInfoBk;
FillRect(Rect);
end;
end;
l_cap := PageControl1.Pages[tabindex].caption;
l_Rect := Rect;
DrawText(PageControl1.Canvas.Handle,Pchar(l_Cap),Length(l_cap),l_Rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var l_cap :String;
l_rect:Trect;
begin
if TabIndex=PageControl1.TabIndex then
begin
with PageControl1.Canvas do
begin
// Font.Color := clBlue;
Brush.Color := clInfoBk;
FillRect(Rect);
end;
end;
l_cap := PageControl1.Pages[tabindex].caption;
l_Rect := Rect;
DrawText(PageControl1.Canvas.Handle,Pchar(l_Cap),Length(l_cap),l_Rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
#2
up
#3
//写了才发现和xyc189()的代码类似~~
//if TabIndex=PageControl1.TabIndex then 可以换成Active来判断~~
uses Types;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
S: string;
vRect: TRect;
begin
Control.Canvas.FillRect(Rect);
vRect := Rect;
if not Active then OffsetRect(vRect, 0, 3);
S := TPageControl(Control).Pages[TabIndex].Caption;
DrawText(Control.Canvas.Handle, PChar(S), Length(S), vRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end;
//if TabIndex=PageControl1.TabIndex then 可以换成Active来判断~~
uses Types;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
S: string;
vRect: TRect;
begin
Control.Canvas.FillRect(Rect);
vRect := Rect;
if not Active then OffsetRect(vRect, 0, 3);
S := TPageControl(Control).Pages[TabIndex].Caption;
DrawText(Control.Canvas.Handle, PChar(S), Length(S), vRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end;
#4
xyc189是可行的
#5
up
#6
关注
#7
感谢各位的解答,上面的代码基本上能够满足要求,但是好像标头还是有点颜色是改变不了的,可能只能达到这种效果了,如果有什么方法能完全修改,望各位再帮看看,先结贴了
#1
把ownerDraw设为True,在OnDrawTab中写
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var l_cap :String;
l_rect:Trect;
begin
if TabIndex=PageControl1.TabIndex then
begin
with PageControl1.Canvas do
begin
// Font.Color := clBlue;
Brush.Color := clInfoBk;
FillRect(Rect);
end;
end;
l_cap := PageControl1.Pages[tabindex].caption;
l_Rect := Rect;
DrawText(PageControl1.Canvas.Handle,Pchar(l_Cap),Length(l_cap),l_Rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var l_cap :String;
l_rect:Trect;
begin
if TabIndex=PageControl1.TabIndex then
begin
with PageControl1.Canvas do
begin
// Font.Color := clBlue;
Brush.Color := clInfoBk;
FillRect(Rect);
end;
end;
l_cap := PageControl1.Pages[tabindex].caption;
l_Rect := Rect;
DrawText(PageControl1.Canvas.Handle,Pchar(l_Cap),Length(l_cap),l_Rect,DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
#2
up
#3
//写了才发现和xyc189()的代码类似~~
//if TabIndex=PageControl1.TabIndex then 可以换成Active来判断~~
uses Types;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
S: string;
vRect: TRect;
begin
Control.Canvas.FillRect(Rect);
vRect := Rect;
if not Active then OffsetRect(vRect, 0, 3);
S := TPageControl(Control).Pages[TabIndex].Caption;
DrawText(Control.Canvas.Handle, PChar(S), Length(S), vRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end;
//if TabIndex=PageControl1.TabIndex then 可以换成Active来判断~~
uses Types;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
S: string;
vRect: TRect;
begin
Control.Canvas.FillRect(Rect);
vRect := Rect;
if not Active then OffsetRect(vRect, 0, 3);
S := TPageControl(Control).Pages[TabIndex].Caption;
DrawText(Control.Canvas.Handle, PChar(S), Length(S), vRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end;
#4
xyc189是可行的
#5
up
#6
关注
#7
感谢各位的解答,上面的代码基本上能够满足要求,但是好像标头还是有点颜色是改变不了的,可能只能达到这种效果了,如果有什么方法能完全修改,望各位再帮看看,先结贴了