我在使用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)