delphi中,panel控件如何实现透明化,请高手指点
2013-05-26
展开全部
使用第三方控件RzPanel,有transparent属性,设置为true即可
展开全部
利用PanelTransparent这个unit来实现即可。
unit PanelTransparent;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TPanelTransparent = class (TPanel)
private
procedure CnCtlColorStatic (var Msg: TWMCtlColorStatic); message CN_CTLCOLORSTATIC;
procedure WmEraseBkgnd (var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure Paint; override;
protected
procedure CreateParams (var Params: TCreateParams); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents ('AppMic', [TPanelTransparent]);
end;
procedure TPanelTransparent.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TPanelTransparent.WmEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 1;
end;
procedure TPanelTransparent.CnCtlColorStatic(var Msg: TWMCtlColorStatic);
begin
SetBKMode (Msg.ChildDC, TRANSPARENT);
Msg.Result := GetStockObject (NULL_BRUSH);
end;
procedure TPanelTransparent.Paint;
begin
SetBKMode (Handle, TRANSPARENT);
//inherited;
end;
end.
unit PanelTransparent;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TPanelTransparent = class (TPanel)
private
procedure CnCtlColorStatic (var Msg: TWMCtlColorStatic); message CN_CTLCOLORSTATIC;
procedure WmEraseBkgnd (var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure Paint; override;
protected
procedure CreateParams (var Params: TCreateParams); override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents ('AppMic', [TPanelTransparent]);
end;
procedure TPanelTransparent.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;
procedure TPanelTransparent.WmEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 1;
end;
procedure TPanelTransparent.CnCtlColorStatic(var Msg: TWMCtlColorStatic);
begin
SetBKMode (Msg.ChildDC, TRANSPARENT);
Msg.Result := GetStockObject (NULL_BRUSH);
end;
procedure TPanelTransparent.Paint;
begin
SetBKMode (Handle, TRANSPARENT);
//inherited;
end;
end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-05-26
展开全部
你说的透明化,什么意思?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询