包含图形、动画、进度条等等的状态栏

{
在Delphi中,一个控件上能否成为其它控件的父控件取决于此控件的ControlStyle属性。
ControlStyle属性是集合类型的,如果此集合包含csAcceptsControls元素,
则它能接受其它控件;否则,它就不能成为其它控件的父控件。
ControlStyle属性只能在控件的构造函数(Constructor)中指定,
在程序运行时它是不能被改变的。所以如果希望窗口状态条上面能包含其它控件,
我们只需要在继承类中重载TStatusBar控件的Constructor函数,
并且让控件的集合属性ControlStyle中包含csAcceptsControls即可。
}

unit StatusBarEx;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics,
 Controls, Forms, Dialogs, ComCtrls;

type
 TStatusBarEx = class(TStatusBar)
 public
   constructor Create(AOwner: TComponent); override;
 end;

procedure Register;

implementation

constructor TStatusBarEx.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 {为了让TStatusBarEx控件能接受其它控件,必须
 使ControlStyle属性(集合类型)包含csAcceptsControls元素}
 ControlStyle:= ControlStyle + [csAcceptsControls];
end;

procedure Register;
begin
 RegisterComponents('Win32', [TStatusBarEx]);
end;

end.

 

posted @ 2008-04-01 14:11  delphi中间件  阅读(367)  评论(0编辑  收藏  举报