如何实现透明PANEL

13023600339 2005-09-19 03:28:05
如何实现透明PANEL或有现成的控件可下载?请大家告知,谢谢
...全文
271 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
g961681 2005-09-19
  • 打赏
  • 举报
回复
建议用Raise中的TRzPanel,不但可以直接用,还能看到它的源代码!
楚人无衣 2005-09-19
  • 打赏
  • 举报
回复
简单一些的,设其ParentColor为True不行吗
13023600339 2005-09-19
  • 打赏
  • 举报
回复
现在项目需要,得自己写透明PANEL的代码,二楼的代码运行期不能透明,大家能不能再提供源码?
楚人无衣 2005-09-19
  • 打赏
  • 举报
回复
Raise中的TRzPanel,有Transparent属性,很好用
13023600339 2005-09-19
  • 打赏
  • 举报
回复
有没有现在的PANEL控件?
gxgyj 2005-09-19
  • 打赏
  • 举报
回复
别人的//////////////
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit MyPanel;

interface

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

type
TMyPanel = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
procedure Paint; override;
public
{ Public declarations }
published
{ Published declarations }
end;

procedure Register;

implementation
procedure DrawParentImage(Control: TControl; Dest: TCanvas);
var
SaveIndex: Integer;
DC: HDC;
Position: TPoint;
begin
with Control do
begin
if Parent = nil then
Exit;
DC := Dest.Handle;
SaveIndex := SaveDC(DC);
{$IFDEF DFS_COMPILER_2}
GetViewportOrgEx(DC, @Position);
{$ELSE}
GetViewportOrgEx(DC, Position);
{$ENDIF}
SetViewportOrgEx(DC, Position.X - Left, Position.Y - Top, nil);
IntersectClipRect(DC, 0, 0, Parent.ClientWidth, Parent.ClientHeight);
Parent.Perform(WM_ERASEBKGND, DC, 0);
Parent.Perform(WM_PAINT, DC, 0);
RestoreDC(DC, SaveIndex);
end;
end;

procedure Register;
begin
RegisterComponents('Samples', [TMyPanel]);
end;

procedure TMyPanel.Paint;
var
Bitmap: TBitmap;
begin

if not (csDesigning in ComponentState) then
exit;
Bitmap := TBitmap.Create;
try
Bitmap.Height := ClientRect.Bottom;
Bitmap.Width := ClientRect.Right;

DrawParentImage(Self, Bitmap.Canvas);


canvas.CopyRect(ClientRect, Bitmap.canvas, ClientRect);
finally
Bitmap.free;
end;
end;

end.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yaccor 2005-09-19
  • 打赏
  • 举报
回复
帮忙顶一下

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧