如何实现透明PANEL 如何实现透明PANEL或有现成的控件可下载?请大家告知,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 别人的//////////////~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~unit MyPanel;interfaceuses 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;implementationprocedure 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. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Raise中的TRzPanel,有Transparent属性,很好用 现在项目需要,得自己写透明PANEL的代码,二楼的代码运行期不能透明,大家能不能再提供源码? 简单一些的,设其ParentColor为True不行吗 建议用Raise中的TRzPanel,不但可以直接用,还能看到它的源代码! delphi5中dbgrid的问题 DELPHI三层架构免费发布 关于Application.Terminate 欢迎大家下载我的软件,下载者有分. 在DbGrid1中如何让字段以*显示? 讨论:Delphi的编译器的特点 自编函数:处理中文日期 、处理BDE数据库别名、查找目录文件... 请问如何获得dos下的消息,我执行一个dos计算程序后,如何获得它的输出结果了? Alter TABLE add添加字段时参数的问题 一个关于SQL的问题 关于文件操作 richedit 添加trf格式数据出现richedit line insertion error错误的问题?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit MyPanel;interfaceuses
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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~