TPanel的哪个属性用于获取这个阴影?

时间:2016-08-25 19:42:02

标签: user-interface delphi

我想知道如何在Get It Package Manager窗口中实现阴影效果。阴影区域标记为红色。

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

1 个答案:

答案 0 :(得分:12)

TPanel没有属性可以创建该影子。

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

怀疑效果最有可能是通过在顶部Margin下方定义底部TPanel,然后自定义绘制渐变(例如使用GraphUtil.GradientFillCanvas()来完成})到该边距区域内的父表格上。

我能够使用以下测试代码在10.0 Seattle中重现效果:

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