• VCL控件透明


    代码
      TestPanel = class(Tpanel)
      
    public
        procedure Paint; 
    override;
      end;
      
     procedure TestPanel.Paint;
    var
      R: TRect;
    begin
      inherited;
      R :
    = ClientRect;
      DrawParentBackground(Self, Canvas.Handle, @R, True);  
    //透明 不透明则  DrawParentBackground(Self, Canvas.Handle)
    end;

    procedure DrawParentBackground(Control: TControl; DC: HDC; R: PRect 
    = nil;
      bDrawErasebkgnd: Boolean 
    = False);
    var
      LastOrigin: TPoint;
    begin
      GetWindowOrgEx(DC, LastOrigin);
      Control.Parent.Perform(WM_ERASEBKGND, Integer(DC), Integer(DC));
      Control.Parent.Perform(WM_PAINT, Integer(DC), Integer(DC));
      SetWindowOrgEx(DC, LastOrigin.X, LastOrigin.Y, nil);
    end;


    // 测试DEMO
    procedure TForm1.Button1Click(Sender: TObject);
    var
      T1: TestPanel;
    begin
      T1 :
    = TestPanel.Create(Self);
      T1.Left :
    = 100;
      T1.Caption :
    = 'dd';
      T1.Parent :
    = Self;
    end;
  • 相关阅读:
    正则表达式
    70. 爬楼梯
    最大子序和
    动态规划
    中序遍历
    两数相加基础
    保证一个线程最后执行或者最先执行CyclicBarrier
    保证一个线程最后执行使用CountDownLatch
    两个线程交替执行
    单列模式double check的问题
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1648675.html
Copyright © 2020-2023  润新知