您不想要一个完整的玻璃窗口,但您将不得不自己绘制选项卡,因为我不知道有什么控件可以给您所需的确切外观。如果使用当前表单的GlassFrame属性,启用它并将顶部设置为选项卡所需的高度,在此区域放置一个paintbox,并使用GDI+调用手动绘制选项卡。可用于此的一个很好的库在EDN上可用(
http://cc.embarcadero.com/Download.aspx?id=26950)。如果不使用GDI+,您将能够绘制到paint box中,但黑色将变成透明。使用GDI+,您可以以任何颜色自由绘制到玻璃上。例如:
![running example](https://istack.dev59.com/8ZcIV.webp)
来源:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, GdiPlusHelpers, GdiPlus, StdCtrls, ExtCtrls;
type
TForm6 = class(TForm)
pb1: TPaintBox;
procedure pb1Paint(Sender: TObject);
private
public
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.pb1Paint(Sender: TObject);
var
Graphics : IGPGraphics;
Brush: IGPSolidBrush;
FontFamily: IGPFontFamily;
Font: IGPFont;
Point: TGPPointF;
Pen: IGPPen;
begin
Graphics := Pb1.ToGPGraphics;
Brush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 0));
FontFamily := TGPFontFamily.Create('Consolas');
Font := TGPFont.Create(FontFamily, 12, FontStyleRegular, UnitPoint);
Point.Initialize(1, 0);
Graphics.TextRenderingHint := TextRenderingHintAntiAlias;
Graphics.DrawString('GDI+ Black Text', Font, Point, Brush);
Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0));
Graphics.DrawLine(Pen, 0, 0, 200, 100);
end;
end.
表单:
object Form6: TForm6
Left = 0
Top = 0
Caption = 'Form6'
ClientHeight = 282
ClientWidth = 418
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
GlassFrame.Enabled = True
GlassFrame.Top = 22
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object pb1: TPaintBox
Left = 0
Top = 0
Width = 313
Height = 105
OnPaint = pb1Paint
end
end
编辑:已更新文本反锯齿处理,使其看起来更好。