Thema: Delphi TPanel transparent ?

Einzelnen Beitrag anzeigen

taktaky
(Gast)

n/a Beiträge
 
#23

Re: TPanel transparent ?

  Alt 30. Sep 2007, 11:03
Ich habe den Code in ein neues Project, dann die visuale Objekte erstellt
Delphi-Quellcode:
unit TransparentPanel;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm);
  TTransparentPanel = class(TCustomPanel)
    TransparentPanel: TPanel;
    Bevel: TBevel;

  private
  procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
  protected
    { Protected declarations }
  Procedure Paint; override;
  Procedure CreateParams(var Params : TCreateParams); override;
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AComponent: TComponent);override;
  published
    { Published declarations }
    Property BevelInner;
    Property BevelOuter;
    Property Align;
    Property Caption;
    property OnClick;
  end;

var
  Form1: TForm1;

  procedure Register;
implementation
procedure Register;
begin
  RegisterComponents('Shamora', [TTransparentPanel]);
end;

constructor TTransparentPanel.Create(AComponent: TComponent);
begin
  inherited;
  ControlStyle := ControlStyle - [csOpaque];
end;

Procedure TTransparentPanel.Paint;
var
  Rect: TRect;
  TopColor, BottomColor: TColor;
const
  Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);

  procedure AdjustColors(Bevel: TPanelBevel);
  begin
    TopColor := clBtnHighlight;
    if Bevel = bvLowered then TopColor := clBtnShadow;
    BottomColor := clBtnShadow;
    if Bevel = bvLowered then BottomColor := clBtnHighlight;
  end;

begin
  Rect := GetClientRect;
  if BevelOuter < bvNone then
  begin
    AdjustColors(BevelOuter);
    Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
  end;
  Frame3D(Canvas, Rect, Color, Color, BorderWidth);
  if BevelInner < bvNone then
  begin
    AdjustColors(BevelInner);
    Frame3D(Canvas, Rect, TopColor, BottomColor, BevelWidth);
  end;
end;

Procedure TTransparentPanel.CreateParams(var Params : TCreateParams);
Begin
  inherited CreateParams(Params);
  With Params do
  begin
    ExStyle := ExStyle or WS_EX_TRANSPARENT;
    Style := Style and not WS_CLIPCHILDREN;
    Style := Style and not WS_CLIPSIBLINGS;
  end;
End;

procedure TTransparentPanel.WMEraseBkgnd(var Message: TWmEraseBkgnd);
begin
  Message.Result := -1;
end;

{$R *.dfm}

end.
Ich bekomme ich die Meldung:
EclassNotFound with Message Class TBevel not found

Objekte in meinem Form :
Delphi-Quellcode:
object Form1: TForm1
  Left = 221
  Top = 115
  Width = 615
  Height = 587
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Bevel: TBevel
    Left = 20
    Top = 20
    Width = 461
    Height = 441
  end
  object Panel: TPanel
    Left = 40
    Top = 40
    Width = 421
    Height = 401
    Caption = 'Panel'
    TabOrder = 0
  end
end


________
  Mit Zitat antworten Zitat