有透明的Panel控件吗?(200分)

  • 主题发起人 主题发起人 helloo
  • 开始时间 开始时间
H

helloo

Unregistered / Unconfirmed
GUEST, unregistred user!
give me that!
200 is yours!
 
呵呵,
我的了,一会给你寄。
 
受到你的控件了。不过是D3版的。
有D4版的吗?
 
接受答案了.
 
临时写的, 应该能工作.
type
TransparentPanel = class(TPanel)
private
FTransparent: Boolean;

procedure SetTransparent(value: Boolean);
procedure WMEraseBkgnd(var Msg: TMessage); message WM_ERASEBKGND;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure SetParent(AParent: TWinControl); override;
public
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
property Transparent: Boolean read FTransparent write SetTransparent;
end;

implimentation
procedure TTransparentPanel.SetTransparent(value: boolean);
begin
if ftransparent <> value then
begin
ftransparent := value;
invalidate;
end;
end;

procedure TTransparentPanel.WMEraseBkgnd(var Msg: TMessage);
begin
if ftransparent then msg.result := 1
else inherited;
end;

procedure TTransparentPanel.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
params.exstyle := params.exstyle or WS_EX_TRANSPARENT;
end;

procedure TTransparentPanel.SetParent(AParent: TWinControl);
begin
inherited setparent(aparent);
if (aparent <> nil) and aparent.HandleAllocated
and (GetWindowLong(aparent.handle, GWL_STYLE) and WS_CLIPCHILDREN <> 0) then
setwindowlong(aparent.handle, GWL_STYLE,
GetWindowLong(aparent.handle, GWL_STYLE)
and not WS_CLIPCHILDREN);
end;

procedure TTransparentPanel.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
invalidate;
inherited setbounds(aleft, atop, awidth, aheight);
end;

end.
 

Similar threads

回复
0
查看
1K
不得闲
D
回复
0
查看
909
DelphiTeacher的专栏
D
D
回复
0
查看
704
DelphiTeacher的专栏
D
后退
顶部