问题描述
我是Delphi的新手(再次-我在1994年使用Delphi).我现在有Delphi 2009 Pro.
I'm new to Delphi (again - I used Delphi back in 1994). I now have Delphi 2009 Pro.
来自Java,我发现对象继承非常模糊.
Coming from Java, I find the object inheritance very obscure.
我的用户想要左侧带有标签的选项卡式页面.但是,TPageControl不允许更改选项卡标签的方向或方向.他们希望选项卡上的单词在旋转字母的情况下自上而下阅读,因此它们处于正常"方向.左侧的标签使标签从下向上读取,并且字母旋转了90度.向左倾斜,并且倾向于将头向左倾斜以阅读选项卡.我发现了对标准TPageControl VCL的一些增强,它们为图像的悬停和活动添加了图像,文本和颜色更改,但没有任何一项允许在选项卡上操纵字体方向或方向.
My users want tabbed pages with the tabs on the left. But, the TPageControl doesn't allow the tab label direction or orientation to be changed. They want the words on the tabs to read top to bottom with the letters rotated so they are in a "normal" orientation. With the tabs on the left the labels read from the bottom up with the letters rotated 90 deg. to the left and there is a tendency to tilt your head to the left to read the tabs. I found several enhancements to the standard TPageControl VCL that add images, text and color changes for hover and active, but nothing that allows the manipulation of font direction or orientation on the tabs.
页面控制表应类似于:
P
一个
g
e
1
P
a
g
e
1
P
一个
g
e
2
P
a
g
e
2
P
一个
g
e
3
P
a
g
e
3
依此类推...
推荐答案
1.)设置TPageControl属性:
1.) set the TPageControl properties:
TabPosition := tpLeft;
OwnerDraw := True;
TabWidth := 180; //set to any adequate value because
// TPageControl doesn't have a measure event handler
2.)使用以下OnDrawTab代码:
2.) use the following OnDrawTab code:
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
I: Integer;
PageControl: TPageControl;
TextFormat: TTextFormat;
Text: string;
TextRect: TRect;
begin
PageControl := Control as TPageControl;
Text := PageControl.Pages[TabIndex].Caption;
for I := Length(Text) - 1 downto 1 do
begin
Text := Copy(Text, 1, I) + sLineBreak + Copy(Text, I+1, MaxInt);
end;
TextRect := Rect;
TextRect.Left := TextRect.Left + 5;
TextRect.Top := TextRect.Top + 3;
TextFormat := [tfCenter];
PageControl.Canvas.TextRect(
TextRect,
Text,
TextFormat
);
end;
3.)编译,开始并享受!
这篇关于如何更改TPageControl上标签的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!