本文介绍了在Delphi中的XPManifest之后设置TTabControl颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表单上有tabcontrol组件.放入XPManifest后,其颜色变为白色,我想对其进行更改,但找不到颜色属性.而且我也不想删除XPManifest.有什么办法可以解决这个问题?
I have tabcontrol component on my form. After I put XPManifest, its color became white, I want to change it, but couldn't find color property. And I don't want to remove XPManifest as well. Is there any way to solve this issue?
推荐答案
要更改TTabControl的颜色,必须将 OwnerDraw 属性设置为true 并编写自己的代码来绘制 OnDrawTab 事件中的标签和背景.
To change the color of a TTabControl must put the OwnerDraw property to true and write your own code to draw the tabs and the background in the OnDrawTab Event.
请参阅此示例.
procedure TForm38.TabControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
y : Integer;
x : Integer;
aRect: TRect;
begin
if Active then
begin
//Fill the tab rect
Control.Canvas.Brush.Color := clWebGainsboro;
Control.Canvas.FillRect(Rect);
//Fill the background
aRect.Left:=1;
aRect.Right:=Control.Width-1;
aRect.Bottom:=Control.Height-1;
aRect.Top:=Rect.Bottom+1;
Control.Canvas.FillRect(aRect);
end
else
begin
//Fill the tab rect
Control.Canvas.Brush.Color := clBtnFace;
Control.Canvas.FillRect(Rect);
end;
y := Rect.Top + ((Rect.Bottom - Rect.Top - Control.Canvas.TextHeight(TTabControl(Control).Tabs[TabIndex])) div 2) + 1;
x := Rect.Left + ((Rect.Right - Rect.Left - Control.Canvas.TextWidth (TTabControl(Control).Tabs[TabIndex])) div 2) + 1;
//draw the tab title
Control.Canvas.TextOut(x,y,TTabControl(Control).Tabs[TabIndex]);
end;
这篇关于在Delphi中的XPManifest之后设置TTabControl颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!