Install Component …”,将TStatusBarEx控件安装。
//文件名:StatusBarEx.pas
unit StatusBarEx;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, ComCtrls, DsgnIntf;
type
//定义About属性的属性编辑器
TAbout = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
//定义TStatusBarEx控件
TStatusBarEx = class(TStatusBar)
private
{ Private declarations }
FAbout:TAbout;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property About: TAbout read FAbout;
end;
procedure Register;
implementation
constructor TStatusBarEx.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{为了让TStatusBarEx控件能接受其它控件,必须
使ControlStyle属性(集合类型)包含csAcceptsControls元素}
ControlStyle:= ControlStyle + [csAcceptsControls];
end;
//以下是TAbout中的成员函数的实现
procedure TAbout.Edit;
begin
Application.MessageBox('TStatusBarEx for Delphi 5'#13#10
+'Written by Simon Liu'#13#10
+'Email:simon_liu@263.net',
'About TStatusBarEx',MB_ICONINFORMATION);
end;
function TAbout.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
function TAbout.GetValue: string;
begin
Result := '(Simon)';
end;
procedure Register;
begin
//将TStatusBarEx控件注册到Delphi 5控件板的Win32页上
RegisterComponents('Win32', [TStatusBarEx]);
//为About属性注册属性编辑器
RegisterPropertyEditor(typeInfo(TAbout), TStatusBar,
'About', TAbout);
end;
end.
---- 使用TStatusBarEx控件,我们可以非常容易地在StatusBar上增添其它的内容了。比如,如果想要在状态条上显示一个图片,只要在TStatusBarEx控件上放一个Image控件;想要添加一个进度条,只需在上面加一个ProgressBar就行了!
……