gpt4 book ai didi

user-interface - 使用 TPanel 的哪个属性来获取此阴影?

转载 作者:行者123 更新时间:2023-12-03 15:39:46 25 4
gpt4 key购买 nike

我想知道“获取包管理器”窗口中的阴影效果是如何实现的。阴影区域标记为红色。

TPanel 中是否有任何属性可以实现此目的,或者是自定义绘制的? enter image description here

最佳答案

TPanel 没有属性来创建该阴影。

使用 Spy++,我可以看到 GetIt Package Manager 窗口使用 3 个标准 TPanel 对象(其中包含其他控件),并且顶部 TPanel 之间没有其他控件 对象和两个较低的 TPanel 对象。

怀疑这种效果很可能是通过在顶部TPanel下方定义底部Margin来实现的,然后自定义绘制渐变(例如与 GraphUtil.GradientFillCanvas() 一样)到该边距区域内的父表单上。

我能够使用以下测试代码在 10.0 西雅图重现效果:

unit Unit2;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
TForm2 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

uses
GraphUtil;

procedure TForm2.FormPaint(Sender: TObject);
var
R: TRect;
begin
R := ClientRect;
R.Top := Panel1.Top + Panel1.Height;
R.Bottom := Panel2.Top;
GradientFillCanvas(Canvas, clGray, clWhite, R, gdVertical);
end;

end.

object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 266
ClientWidth = 622
Color = clWhite
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
AlignWithMargins = True
Left = 0
Top = 0
Width = 622
Height = 41
Margins.Left = 0
Margins.Top = 0
Margins.Right = 0
Align = alTop
BevelOuter = bvNone
Caption = 'Panel1'
ParentBackground = False
TabOrder = 0
ExplicitLeft = 224
ExplicitTop = 128
ExplicitWidth = 185
end
object Panel2: TPanel
AlignWithMargins = True
Left = 0
Top = 47
Width = 185
Height = 219
Margins.Left = 0
Margins.Bottom = 0
Align = alLeft
Caption = 'Panel2'
TabOrder = 1
ExplicitLeft = 224
ExplicitTop = 128
ExplicitHeight = 41
end
object Panel3: TPanel
AlignWithMargins = True
Left = 191
Top = 47
Width = 431
Height = 219
Margins.Right = 0
Margins.Bottom = 0
Align = alClient
Caption = 'Panel3'
TabOrder = 2
ExplicitLeft = 224
ExplicitTop = 128
ExplicitWidth = 185
ExplicitHeight = 41
end
end

screenshot

关于user-interface - 使用 TPanel 的哪个属性来获取此阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39153520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com