• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

bcb/delphi透明Panel控件源代码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

http://www.pudn.com/downloads185/sourcecode/delphi_control/detail867452.html

 TrPanel 透明Panel控件源码

  透明Panel
  .........\TransPanel.dcu
  .........\TransPanel.pas

TransPanel.pas  源码

http://read.pudn.com/downloads185/sourcecode/delphi_control/867452/%E9%80%8F%E6%98%8EPanel/TransPanel.pas__.htm

unit TransPanel; 
interface 
uses {WinTypes, WinProcs,}Windows, Messages, SysUtils, Classes, Controls, Forms, 
  Graphics, StdCtrls; 
type 
  TTransPanel = class(TCustomcontrol) 
  private 
    Fborder: Boolean; 
    FAlignment: TAlignment; 
    procedure Setborder(Value: Boolean); 
    procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND; 
    procedure SetAlignment(const Value: TAlignment); 
  protected 
    procedure Paint; override; 
  public 
    procedure CreateParams(var Params: TCreateParams); override; 
    constructor Create(AOwner: TComponent); override; 
    destructor Destroy; override; 
  published 
    property Alignment: TAlignment read FAlignment write SetAlignment default 
      taCenter; 
    property Anchors; 
    property Border: Boolean read Fborder write Setborder; 
    property Caption; 
    property Font; 
    property Visible; 
    property Enabled; 
    property Align; 
    property OnClick; 
    property OnMouseDown; 
    property OnMouseMove; 
    property OnMouseUp; 
  end; 
procedure Register; 
implementation 
procedure Register; 
begin 
  RegisterComponents('TransPanel', [TTransPanel]); 
end; 
{ TTransPanel } 
constructor TTransPanel.Create(AOwner: TComponent); 
begin 
  inherited Create(AOwner); 
  Width := 185; 
  Height := 41; 
  FAlignment := taCenter; 
end; 
destructor TTransPanel.Destroy; 
begin 
  inherited Destroy; 
end; 
procedure TTransPanel.CreateParams(var Params: TCreateParams); 
begin 
  inherited CreateParams(Params); 
  Params.ExStyle := Params.ExStyle + WS_EX_Transparent; 
  ControlStyle := ControlStyle - [csOpaque] + [csAcceptsControls]; 
end; 
procedure TTransPanel.Paint; 
const 
  Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER); 
var 
  Rect: TRect; 
  FontHeight: Integer; 
  Flags: Longint; 
begin 
  inherited Paint; 
  Rect := GetClientRect; 
  with Canvas do 
  begin 
    if Fborder or (csDesigning in ComponentState) then 
    begin 
      Canvas.Brush.Color := clBtnShadow; 
      Canvas.FrameRect(Rect); 
    end; 
    Brush.Style := bsClear; 
    Font := Self.Font; 
    FontHeight := TextHeight('W'); 
    with Rect do 
    begin 
      Top := ((Bottom + Top) - FontHeight) div 2; 
      Bottom := Top + FontHeight; 
    end; 
    Flags := DT_EXPANDTABS or DT_VCENTER or Alignments[FAlignment]; 
    Flags := DrawTextBiDiModeFlags(Flags); 
    DrawText(Handle, PChar(Caption), -1, Rect, Flags); 
  end; 
end; 
procedure TTransPanel.Setborder(Value: Boolean); 
begin 
  if Value <> Fborder then 
  begin 
    Fborder := Value; 
    Invalidate; 
  end; 
end; 
procedure TTransPanel.WMEraseBkgnd(var Message: TWmEraseBkgnd); 
begin 
  inherited; 
end; 
procedure TTransPanel.SetAlignment(const Value: TAlignment); 
begin 
  FAlignment := Value; 
  Invalidate; 
end; 
end. 



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
matlab中导入excel数据画图 - lululian发布时间:2022-07-18
下一篇:
EXCEL批量导入MATLAB方法发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap