var pb: TProgressBar; begin .... pb:= TProgressBar.Create(self); with pb do begin Parent:= StatusBar1; Position:= 30; Top:= 2; Left:= 0; Height:= StatusBar1.Height - Top; Width:= StatusBar1.Panels[0].Width - Left; end; //with; pb.Visible:= True; .... end; |
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. end. |