merhaba Hiç Komponet Geliştirmedim Ama Murat Abinin Yazdığı Çok Güzel Bir Mps Button Bileşeni var.Forumda Dosya da var.Ben Kaynağını aşağı yazayım.
{ *** Birden fazla bileşen kullanarak tek bir bileşen oluşturma *** Murat Turan
Aşağıdaki kodu boş bir üniteye yapıştırıp MPSButon.pas adıyla kaydedip delphiye tanıtın veya not defterine yapıştırıp MPSButon.pas ismiyle kaydedin.
Delphiye Nasıl Bileşen Kaydedebilirim? 1."Component" menüsünden "install Component..." komutuna tıklayın. 2.Karşınıza gelen pencereden "Browse..." (Unit file name karşısındaki) komutuna tıklayın 3.Dosyayı hangi konuma kaydettiyseniz o konumdan dosyayı açın (Unit file name karşısına dosya adı ve tam yolu gelecektir) 4.OK komutuna tıklayın 5.Karşınıza yeni gelen pencereden "Compile" komutuna tıklayıp kodu derleyin. 6.Bu işlem sonrası kontrol "Standard" bileşen sekmesine gelecektir. } unit MPSButon;
interface
uses Messages, Classes, Graphics,Controls, Buttons, ExtCtrls, StdCtrls;
type TMBtn = class(TCustomControl)
private FLabel : TLabel; FSpBtn : TSpeedButton; BtnClick : TNotifyEvent; FAlignment : TAlignment; FLayout : TTextLayout;
procedure SetAlignment(Value: TAlignment); procedure SetLayout(Value: TTextLayout);
Function GetButtonText:String; Procedure SetButtonText(const Value:String);
Function GetZeminRengi:TColor; Procedure SetZeminRengi(Const Value:TColor);
Function GetCerceveRengi:TColor; Procedure SetCerceveRengi(Const Value:TColor);
procedure Click(Sender: TObject); protected procedure WmSize(var Message:TMessage);message WM_SIZE; procedure WmFont(var Message:TMessage);message WM_FONTCHANGE; procedure WmEnabled(var Message:TMessage);message WM_ENABLE; public constructor Create(AOwner:TComponent);override; destructor Destroy;Override; published property ButtonText :string read GetButtonText write SetButtonText; property OnClick :TNotifyEvent read BtnClick write BtnClick; Property ZeminRengi :TColor read GetZeminRengi write SetZeminRengi; Property CerceveRengi :TColor read GetCerceveRengi write SetCerceveRengi; property YatayHizalama:TAlignment read FAlignment write SetAlignment; property DikeyHizalama:TTextLayout read FLayout write SetLayout; property Font; property ShowHint; property Action; property Anchors; property Visible; property Tag; property Enabled;
end;
procedure Register;
implementation
procedure Register; begin RegisterComponents('Standard', [TMBtn]); end;
{ TMBtn } //******************************************************************************* procedure TMBtn.Click(Sender: TObject); begin inherited Click; if Assigned(BtnClick) then BtnClick(Self); end; //******************************************************************************* constructor TMBtn.Create(AOwner: TComponent); const SabirLeft = 1; begin inherited Create(AOwner); BevelWidth := 1; Color := clBlue; Caption := ''; BevelOuter := bvNone; BevelInner := bvNone; Height := 27; Width := 83;
FLabel := TLabel.Create(Self); FLabel.Parent := Self; FLabel.Transparent := False; FLabel.Caption :=''; FLabel.Color :=$00C4D7DF; FLabel.AutoSize :=False; FLabel.Left := 1; FLabel.Top := 1; FLabel.Layout := FLayout; FLabel.Alignment := FAlignment;
FSpBtn := TSpeedButton.Create(Self); FSpBtn.Parent := Self; FSpBtn.Flat := True; FSpBtn.Left := 1; FSpBtn.Top := 1; FSpBtn.Height := 25; FSpBtn.Width := 81; FSpBtn.BringToFront;
FSpBtn.OnClick := Click; FSpBtn.Hint := Hint; FSpBtn.ShowHint := ShowHint; end; //******************************************************************************* destructor TMBtn.Destroy; begin FLabel.Free; FSpBtn.Free; inherited Destroy; end; //******************************************************************************* function TMBtn.GetButtonText: String; begin Result := FLabel.Caption; end;
procedure TMBtn.SetButtonText(const Value: String); begin FLabel.Caption := Value; end; //******************************************************************************* function TMBtn.GetZeminRengi: TColor; begin Result := FLabel.Color; end;
procedure TMBtn.SetZeminRengi(Const Value: TColor); begin FLabel.Color := Value; end; //******************************************************************************* function TMBtn.GetCerceveRengi: TColor; begin Result := Self.Color; end;
procedure TMBtn.SetCerceveRengi(const Value: TColor); begin Self.Color := Value; end; //******************************************************************************* procedure TMBtn.WmFont(var Message: TMessage); begin FLabel.Font := Font; end; //******************************************************************************* procedure TMBtn.WmSize(var Message: TMessage); begin FSpBtn.Height := Height -2; FSpBtn.Width := Width -2;
FLabel.Height := Height -2; FLabel.Width := Width -2; end; //******************************************************************************* procedure TMBtn.WmEnabled(var Message: TMessage); begin FSpBtn.Enabled :=Enabled; FLabel.Enabled :=Enabled; end; //******************************************************************************* procedure TMBtn.SetAlignment(Value: TAlignment); begin FAlignment := Value; FLabel.Alignment := FAlignment; end; //******************************************************************************* procedure TMBtn.SetLayout(Value: TTextLayout); begin if FLayout <> Value then begin FLayout := Value; FLabel.Layout := FLayout; end; end; //*******************************************************************************
end.
-------------
|