Thema: Delphi TProgressbar ohne Rahmen

Einzelnen Beitrag anzeigen

Benutzerbild von gizzy
gizzy

Registriert seit: 3. Jun 2007
59 Beiträge
 
Delphi 2007 Enterprise
 
#1

TProgressbar ohne Rahmen

  Alt 12. Feb 2008, 23:10
Hallöchen,

und zwar wollte ich eine Progressbar ohne diesen Standart Rahmen haben. Ich hab mich schon überall durchgewurschtelt und dabei fokgendes gefunden. Leider bin ich nicht so der Delphi "Pro" um das auf anhieb zu verstehen, aber ich glaube ich muss den Quellcode als deue Komponente hinzufügen.
Kann mir da vielleicht jemand einen Tipp geben?

Zitat:

Delphi's ProgressBar always have a frame. If you wish to place it on a StatusBar it looks not beautifully. You can do small change in the component and you'll get the new one without a frame.

http://www.latiumsoftware.com/img/progress.gif

Look the picture (progress.gif). You can see three ProgressBars. One is a standard Delphi's component with a frame and the rest of them a component with a new property. Now you can drive a ProgressBar's frame.

unit NewProgress;

Delphi-Quellcode:
unit NewProgress;

// By Vladimir S. <shvetadvipa@mtu-net.ru>

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);
  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.
Vielen Dank im voraus
David
  Mit Zitat antworten Zitat