zoukankan      html  css  js  c++  java
  • 界面方面的备忘

    1. 透明panel

    unit uWnTransparentPanel;

    interface

    uses
      Windows,Classes,StdCtrls,ExtCtrls,Messages,Forms;

    type
      TWnTransparentPanel = class(TPanel)
      private
        FTransparentPercent: Integer;
        procedure SetTransparentPercent(const Value: Integer);
      protected
        procedure WMPaint(var message : TMessage); message WM_Paint;
      public
        procedure StepShow(const ALeft,ATop,HStet,VStep:Integer);
      published
        property TransparentPercent: Integer read FTransparentPercent write SetTransparentPercent;
      end;

    implementation

    { TWnTransparentPanel }

    procedure TWnTransparentPanel.SetTransparentPercent(const Value: Integer);
    begin
      FTransparentPercent := Value;
    end;

    procedure TWnTransparentPanel.StepShow(const ALeft, ATop,HStet, VStep: Integer);
    var
      I: Integer;
    begin
      Visible := True;
      Left := ALeft;
      Top := ATop+VStep*10  ;
      for I := 0 to 9 do
      begin
        Top := ATop +(9-I)*VStep;
        Self.Parent.Update;
        Self.Repaint;
        Sleep(100);
        Application.HandleMessage;
      end;
    end;

    procedure TWnTransparentPanel.WMPaint(var message: TMessage);
      procedure AlphaBlendTabControl;
      var
      MemBitmap, OldBitmap: HBITMAP;
      BF: BLENDFUNCTION;
      MemDC, DC: HDC;
      begin
        if (Parent = nilor not Parent.HandleAllocated then
        Exit;
        DC := GetDC(0);
        MemBitmap := CreateCompatibleBitmap(DC, Parent.Width, Parent.Height);
        ReleaseDC(0, DC);
        MemDC := CreateCompatibleDC(0);
        OldBitmap := SelectObject(MemDC, MemBitmap);
        try
          Parent.Perform(WM_ERASEBKGND, MemDC, MemDC);
          Parent.Perform(WM_PAINT, MemDC, 0);

          BF.SourceConstantAlpha := TransparentPercent;
          BF.AlphaFormat := 0;
          BF.BlendOp := AC_SRC_OVER;
          BF.BlendFlags := 0;
          Windows.AlphaBlend(Canvas.Handle, 00, Width, Height, MemDC, Left, Top, Width, Height, BF);
        finally
          SelectObject(MemDC, OldBitmap);
          DeleteDC(MemDC);
          DeleteObject(MemBitmap);
        end;
      end;
    begin
      inherited;
      AlphaBlendTabControl;
    end;

    end.

    2. 设计的时候,panel可以用Anchors = [akLeft, akTop, akRight, akBottom] 加上Align = alCustom达到自动预留边框的目的,就可以避免panel用Align = alClient的时候panel贴边的问题

    3. Grid载入数据的时候界面频刷的问题,主要是要Grid paint之初就要设定好高宽,而不是边画边设高宽

  • 相关阅读:
    jmeter使用教程
    Jmeter的好搭档Badboy的安装与简单使用
    十大编程算法助程序员走上高手之路
    polyfillJS生成promise对象
    js+canvas实现滑动拼图验证码功能
    WebAssembly介绍
    解释器与编译器
    使用axios优雅的发起网络请求
    【javascript】script标签的async异步解析
    sass用法快速入门
  • 原文地址:https://www.cnblogs.com/enli/p/2241087.html
Copyright © 2011-2022 走看看