如何实现透明PANEL或有现成的控件可下载?请大家告知,谢谢

解决方案 »

  1.   

    别人的//////////////
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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. 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

  2.   

    Raise中的TRzPanel,有Transparent属性,很好用
      

  3.   

    现在项目需要,得自己写透明PANEL的代码,二楼的代码运行期不能透明,大家能不能再提供源码?
      

  4.   

    简单一些的,设其ParentColor为True不行吗
      

  5.   

    建议用Raise中的TRzPanel,不但可以直接用,还能看到它的源代码!