Enhanced StatusBar Component
by Kevin S. Gallagher - gallaghe@teleport.com
I developed this component as a jumping off point to investigate other enhancements to the status bar component in general. In case you haven't worked with StatusBar's much, the sizegrip may appear in certain circumstances where you don't want it. This component corrects that behavior and also adds the interesting effect that you can drop other components (i.e. buttons) onto the status bar. It generates some interesting possibilities.
Please email me if you have comments or ideas about further enhancements!
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,
ComCtrls, DsgnIntf;
type
TAbout = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes;
override;
function GetValue: string; override;
end;
TDialogStatusbar = class(TStatusBar)
private
FAbout: TAbout;
FSizeGrip: Boolean;
procedure SetUpSizeGrip;
protected
procedure CreateParams(var Params:
TCreateParams); override;
public
constructor Create(AOwner: TComponent);
override;
published
property About: TAbout read FAbout
write FAbout;
end;
procedure Register;
implementation
uses Commctrl;
procedure TAbout.Edit;
begin
Application.MessageBox('TDialogStatusbar component'
+ #13 +
'© 1998 Kevin S. Gallagher - This component
is freeware.',
'About TDialogStatusbar Component', MB_OK
+ MB_ICONINFORMATION);
end;
function TAbout.GetAttributes: TPropertyAttributes;
begin
Result:= [paMultiSelect, paDialog, paReadOnly];
end;
function TAbout.GetValue: string;
begin
Result:= '(about)';
end;
constructor TDialogStatusbar.Create(AOwner: TComponent);
begin
{ Try dropping onto a data form }
if not(AOwner is TForm) then
raise EInvalidOperation.Create('Must
be owned by a standard form');
inherited Create(AOwner);
FSizeGrip := False;
{ This allows you to drop things like labels,
editboxes, gauges, button etc
onto the StatusBar }
ControlStyle := ControlStyle + [csAcceptsControls];
SetUpSizeGrip;
end;
procedure TDialogStatusbar.SetUpSizeGrip;
begin
{ Check to see if this is a sizeable form
or not }
with Owner as TForm do
FSizeGrip := not(BorderStyle
in [bsToolWindow,
bsDialog,
bsNone,
bsSingle]);
SizeGrip := FSizeGrip;
end;
{ Must setup the SizeGrip here }
procedure TDialogStatusbar.CreateParams(var Params:
TCreateParams);
begin
inherited CreateParams(Params);
CreateSubClass(Params, STATUSCLASSNAME);
with Params do begin
{ This is needed to finalize our
task }
SetUpSizeGrip;
if FSizeGrip then
Style := Style or
SBARS_SIZEGRIP
else
Style := Style or
CCS_TOP;
WindowClass.style := WindowClass.style
and not CS_HREDRAW;
end;
end;
procedure Register;
begin
RegisterComponents('Win32', [TDialogStatusbar]);
RegisterPropertyEditor(TypeInfo(TAbout), TDialogStatusbar,
'ABOUT', TAbout);
end;
end.