unit vsprgs;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TNProgressBar = class(TProgressBar)
procedure WMNCPAINT(var Msg: TMessage); message WM_NCPAINT;
private
FShowFrame: boolean;
procedure SetShowFrame(Value: boolean);
protected
public
constructor Create(AOwner: TComponent); override;
published
property ShowFrame: boolean read FShowFrame write SetShowFrame;
end;
procedure Register;
implementation
{ TNProgressBar }
constructor TNProgressBar.Create(AOwner: TComponent);
begin
inherited;
FShowFrame := True;
end;
procedure TNProgressBar.SetShowFrame(Value: boolean);
begin
if FShowFrame <> Value then
begin
FShowFrame := Value;
RecreateWnd;
end;
end;
procedure TNProgressBar.WMNCPAINT(var Msg: TMessage);
var
DC: HDC;
RC: TRect;
begin
if ShowFrame then
begin
inherited;
Invalidate;
end
else
begin
DC := GetWindowDC(Handle);
try
Windows.GetClientRect(Handle, RC);
with RC do
begin
Inc(Right, 2);
Inc(Bottom, 2);
end;
Windows.FillRect(DC, RC, Brush.Handle);
finally
ReleaseDC(Handle, DC);
end;
end;
end;
procedure Register;
begin
RegisterComponents('Controls', [TNProgressBar]);
end;
end.
|