小编c0p*_*t0p的帖子

在创建/恢复表单时,重叠的TCustomControl对象不按顺序绘制

我在使用Delust 2007中获得TCustomControl处理透明度时遇到了问题.我目前已将问题减少到下面的代码中.问题是,在最初创建表单时,控件的绘制顺序与它们添加到表单的顺序相反.调整表单大小后,它们会以正确的顺序绘制.我究竟做错了什么?排除第三方解决方案是否有更合适的路径?

调整窗口大小后,示例程序的屏幕截图

这是我的示例项目,展示了Delphi 2007中的问题.

unit Main;

interface

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

type
  // Example of a TWinControl derived control
  TMyCustomControl = class(TCustomControl)
  protected
    procedure CreateParams(var params: TCreateParams); override;
    procedure WMEraseBkGnd(var msg: TWMEraseBkGnd);
      message WM_ERASEBKGND;
    procedure Paint; override;
  end;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    YellowBox: TMyCustomControl;
    GreenBox: TMyCustomControl;
  end;

var
  Form1: TForm1;

implementation

uses
  Windows, Graphics;

{$R *.dfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  self.OnPaint := FormPaint;

  GreenBox := TMyCustomControl.Create(self);
  GreenBox.Parent …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-2007

8
推荐指数
1
解决办法
621
查看次数

标签 统计

delphi ×1

delphi-2007 ×1