更改选项卡中间标题的字体

发布于 2024-10-20 14:29:53 字数 324 浏览 1 评论 0原文

我正在使用 Delphi 7。

我想在选项卡标题上指示与选项卡相关的页面有内容。如果页面上的 dbgrid 中有内容,我想在标题后面加上一个绕组,用字母 n 表示,显示为一个框。因此,现在标题不再是“患者病史”,而是“患者病史”+一个填满的小盒子。

由于符号是字母“n”,字体类型为 wingding,所以我想更改标题中间的字体类型并添加字母 n,从而在标题末尾形成一个小填充框。

Tabsheet.caption := 'Patient History ' + changefonttypetowinding + 'n'.

可行吗?

I'm using Delphi 7.

I want to indicate on the tab caption that the page related to the tab has content. If there is content in the dbgrid on the page I want to follow the caption with a winding, represented with the letter n which shows up as a box. So now instead of the caption reading 'Paient History' it would read 'Patient History ' + a little filled box.

Since the symbol is the letter 'n' with a font type of wingding I want to change the font type in the middle of the caption and add the letter n resulting in a small filled box at the end of the caption.

Tabsheet.caption := 'Patient History ' + changefonttypetowinding + 'n'.

Doable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凤舞天涯 2024-10-27 14:29:53

你在这里进入了所有者绘制的领域,一旦你考虑到主题,做好这件事就不是一件小事了。如果你确实走那条路,那么我就不会为 Wingdings 烦恼,我只需将盒子绘制为 TCanvas.FillRect 即可。

就我个人而言,我会研究 Unicode Delphi 并使用 U+2587 (▇) 或其朋友之一。

You're into owner-draw territory here and that's not totally trivial to do well once you take into account themes. If you do go that route then I wouldn't bother with Wingdings, I'd just paint the box will a TCanvas.FillRect.

Personally I'd look into a Unicode Delphi and use U+2587 (▇) or one of its friends.

清君侧 2024-10-27 14:29:53

正如 David 所指出的,由于您没有使用支持 Unicode 的 Delphi 版本,因此您只能使用所有者绘图或“ANSI”字符集。 (我的建议是升级到 Delphi 2009+。Unicode 是数字世界中发生过的最好的事情。使用 Unicode,您可以获得数万个字符(理论上,每种字体!),而不是 127 或 255 个。这包括各种语言以及技术和数学符号以及各种符号,甚至还有一个苯环:U+232C BENZENE RING:⌬)

现在我们假设升级是不可能的。那么,如果我是你,我会使用历史上的“标准字符”来达到此目的,即星号(*)。对于你的情况,我强烈推荐这个。

如果你真的想要一个黑色方块,那么你必须进行所有者绘图。您可以这样做:

// Please don't do this -- see comments below
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
const
  Padding = 8;
  SqSize = 6;
var
  capt: string;
  r: TRect;
begin
  capt := TTabControl(Control).Tabs[TabIndex];
  r := Rect;
  r.Left := r.Left + Padding;
  DrawText(Control.Canvas.Handle, capt, length(capt), r, DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
  r.Left := r.Right - Padding - SqSize;
  r.Right := r.Left + SqSize;
  r.Top := (r.Bottom - r.Top - SqSize) div 2;
  r.Bottom := r.Top + SqSize;
  FillRect(Control.Canvas.Handle, r, GetStockObject(BLACK_BRUSH));
end;

但是请注意,这将禁用视觉主题!看起来会很可怕!请不要这样做!

Since you are not using a Unicode-enabled version of Delphi, you are restricted to owner-drawing or the "ANSI" character set, as pointed out by David. (My suggestion is that you upgrade to Delphi 2009+. Unicode is the best thing that has ever happened to the digital world. With Unicode, you get tens of thousands of characters (in theory, per font!) instead of 127 or 255. This includes all sorts of languages as well as technical and mathematical symbols and various dingbats. There is even a benzene ring: U+232C BENZENE RING: ⌬)

Now let's assume that upgrading is not possible. Then, if I were you, I would use the historical "standard character" for this purpose, namely, the asterisk (*). I recommend this very strongly in your case.

If you relly, relly, want a black square, then you must do owner-drawing. You might do it like this:

// Please don't do this -- see comments below
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
const
  Padding = 8;
  SqSize = 6;
var
  capt: string;
  r: TRect;
begin
  capt := TTabControl(Control).Tabs[TabIndex];
  r := Rect;
  r.Left := r.Left + Padding;
  DrawText(Control.Canvas.Handle, capt, length(capt), r, DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS);
  r.Left := r.Right - Padding - SqSize;
  r.Right := r.Left + SqSize;
  r.Top := (r.Bottom - r.Top - SqSize) div 2;
  r.Bottom := r.Top + SqSize;
  FillRect(Control.Canvas.Handle, r, GetStockObject(BLACK_BRUSH));
end;

Notice, however, that this will disable visual themes! It will look dreadful! Please don't do this!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文