IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   Delphi (https://www.ircforumlari.net/delphi/)
-   -   YIL-AY componenti (https://www.ircforumlari.net/delphi/689511-yil-ay-componenti.html)

Kaf_Dağı 18 Mart 2015 14:15

YIL-AY componenti
 
Kod:

unit AyYil;
 
interface
 
uses
 windows,SysUtils, Classes, Controls, ExtCtrls, ComCtrls, Mask, StdCtrls;
 
type
 
 TOptionBtn=(SMaxDt,SMixDt,BtnOncekiAy,BtnSonrakiAy,BtnOncekiYil,BtnSonrakiYil);
 TOptionsBtn = set of TOptionBtn;
 
 TREdit = class(TEdit)
    private
 published
  property Align;
 end;
 
 TRButon = class(TButton)
 published
  property Align;
 end;
 
 TAyYil = class(TPanel)
 private
  Tarih,FMaxDt,FMinDt:TDate;
  FOptionsBtn: TOptionsBtn;
  OYil,OAy,SAy,SYil:TRButon;
  Yaz:TREdit;
  procedure SetMaxDt(Value:TDate);
  procedure SetMixDt(Value:TDate);
  procedure SetOptionsBtn(Value: TOptionsBtn);
  function GYilAy:String;
  { Private declarations }
 protected
  procedure Loaded; override;
  procedure OYilClick(sender:TObject);
  procedure OAyClick(sender:TObject);
  procedure SYilClick(sender:TObject);
  procedure SAyClick(sender:TObject);
  procedure edityaz;
  { Protected declarations }
 public
  constructor Create(AOwner: TComponent); override;
  destructor Destroy; override;
  function YilAyVer(Value:TDateTime):String;
  function TarihDegistir(Value: TDate):Tdate;
  function OncekiAy:TDate;
  function SonrakiAy:TDate;
  function OncekiYil:TDate;
  function SonrakiYil:TDate;
 
  { Public declarations }
 published
  property YilAy:String read GYilAy;
  property Gun:TDate read Tarih;
  property OptionsBtn:TOptionsBtn read FOptionsBtn write SetOptionsBtn;
  property MaxDt:TDate read FMaxDt write SetMaxDt;
  property MinDt:TDate read FMinDt write SetMixDt;
  { Published declarations }
 end;
 
procedure Register;
 
implementation
 
uses DateUtils;
 
procedure Register;
begin
 RegisterComponents('editler', [TAyYil]);
end;
 
{ TAyYil }
 
constructor TAyYil.Create(AOwner: TComponent);
var x:Integer;
begin
 inherited Create(AOwner);
 Height:=25;
 x:=18;
 SetOptionsBtn([BtnOncekiAy,BtnSonrakiAy]);
 Yaz:=TREdit.Create(Self);
 yaz.ReadOnly:=True;
 
 OYil:=TRButon.Create(Self);
 OAy:=TRButon.Create(Self);
 SYil:=TRButon.Create(Self);
 SAy:=TRButon.Create(Self);
 
 Yaz.Parent:=Self;
 OYil.Parent:=Self;
 OAy.Parent:=Self;
 SYil.Parent:=Self;
 SAy.Parent:=Self;
 
 Yaz.Align:=alClient;
 OYil.Align:=alLeft;
 OAy.Align:=alLeft;
 SYil.Align:=alRight;
 SAy.Align:=alRight;
 
 OYil.Width:=x;
 OAy.Width:=x;
 SYil.Width:=x;
 SAy.Width:=x;
 
 OYil.Caption:='<<';
 OAy.Caption:='<';
 SAy.Caption:='>';
 SYil.Caption:='>>';
 
 OYil.Left:=0;
 OAy.Left:=OYil.Width+1;
 SYil.Left:=Width;
 SAy.Left:=SYil.Left-1;
 
 OYil.OnClick:=OYilClick;
 OAy.OnClick:=OAyClick;
 SYil.OnClick:=SYilClick;
 SAy.OnClick:=SAyClick;
 
 OYil.Visible:=False;
 OAy.Visible:=True;
 SAy.Visible:=True;
 SYil.Visible:=False;
 
 Loaded;
end;
 
destructor TAyYil.Destroy;
begin
 Yaz.Free;
 OYil.Free;
 OAy.Free;
 SYil.Free;
 SAy.Free;
 inherited;
end;
 
 
procedure TAyYil.edityaz;
begin
Yaz.Text:=copy(DateToStr(Tarih),7,4)+copy(DateToStr(Tarih),4,2);
end;
 
 
function TAyYil.GYilAy: String;
begin
Result:=Yaz.Text;
end;
 
procedure TAyYil.Loaded;
begin
 inherited;
Tarih:=Date;
Tarih:=StrToDate('01.'+copy(DateToStr(Tarih),4,2)+'.'+copy(DateToStr(Tarih),7,4));
edityaz;
OAy.Visible:=(BtnOncekiAy in OptionsBtn);
SAy.Visible:=(BtnSonrakiAy in OptionsBtn);
OYil.Visible:=(BtnOncekiYil in OptionsBtn);
SYil.Visible:=(BtnSonrakiYil in OptionsBtn);
end;
 
procedure TAyYil.OAyClick(sender: TObject);
begin
Tarih:=IncMonth(Tarih,-1);
if (SMixDt in OptionsBtn) then
 if Tarih<MinDt then
  Tarih:=MinDt;
edityaz;
if Assigned (OnClick) then  OnClick(self);
end;
 
function TAyYil.OncekiAy: TDate;
begin
Result:=IncMonth(Tarih,-1);
end;
 
function TAyYil.OncekiYil: TDate;
begin
Result:=IncYear(Tarih,-1);
end;
 
procedure TAyYil.OYilClick(sender: TObject);
begin
Tarih:=IncYear(Tarih,-1);
if (SMixDt in OptionsBtn) then
 if Tarih<MinDt then
  Tarih:=MinDt;
edityaz;
if Assigned (OnClick) then  OnClick(self);
end;
 
procedure TAyYil.SAyClick(sender: TObject);
begin
Tarih:=IncMonth(Tarih,1);
if (SMaxDt in OptionsBtn) then
 if Tarih>MaxDt then
  Tarih:=MaxDt;
edityaz;
if Assigned (OnClick) then  OnClick(self);
end;
 
 
procedure TAyYil.SetMaxDt(Value: TDate);
begin
FMaxDt:=Value;
end;
 
procedure TAyYil.SetMixDt(Value: TDate);
begin
FMinDt:=Value;
end;
 
procedure TAyYil.SetOptionsBtn(Value: TOptionsBtn);
begin
FOptionsBtn:=Value;
end;
 
function TAyYil.SonrakiAy: TDate;
begin
Result:=IncMonth(Tarih,1);
end;
 
function TAyYil.SonrakiYil: TDate;
begin
Result:=IncYear(Tarih,1);
end;
 
procedure TAyYil.SYilClick(sender: TObject);
begin
Tarih:=IncYear(Tarih,1);
if (SMaxDt in OptionsBtn) then
 if Tarih>MaxDt then
  Tarih:=MaxDt;
edityaz;
if Assigned (OnClick) then  OnClick(self);
end;
 
function TAyYil.TarihDegistir(Value: TDate):Tdate;
begin
Tarih:=Value;
Tarih:=StrToDate('01.'+copy(DateToStr(Tarih),4,2)+'.'+copy(DateToStr(Tarih),7,4));
edityaz;
result:=Tarih;
end;
 
function TAyYil.YilAyVer(Value: TDateTime): String;
begin
Result:=copy(DateToStr(Value),7,4)+copy(DateToStr(Value),4,2);
end;
 
end.



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 05:46.

Powered by vBulletin® Version 3.8.8 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2024 IRCForumlari.Net