Solved

calendar component for application

Posted on 2004-03-21
9
433 Views
Last Modified: 2010-04-05
hi
i need a small cool calendar component because i don't like the one that is offered with delphi

so i can build it in thank you


i tried delphipages.com but couldn't find it


thank you
0
Comment
Question by:zgeorge_2
9 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 42 total points
ID: 10645998
0
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 41 total points
ID: 10646050
or Delphi Super Page

http://delphi.icm.edu.pl/

or www.delphi32.com

Shane
0
 
LVL 4

Assisted Solution

by:k4hvd77
k4hvd77 earned 41 total points
ID: 10647027
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:calinutz
ID: 10647048
If you don't like the appearance of the calendar you can always full around with it's settings: Calcolors .
You can make it look pretty nice in the end.
Cheers
0
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 41 total points
ID: 10648398
unit eCalendar;

interface

uses
  SysUtils, Classes, Messages, Controls, StdCtrls, ExtCtrls,
  Grids, Calendar;

type
  TeCustomCalendar = class(TCalendar)
  private        { Private declarations }
  protected      { Protected declarations }
    procedure      Click; override;
  public         { Public declarations }
  published      { Published declarations }
  end;

  TeEdit = class(TEdit)
  private        { Private declarations }
    FKeyPress:     TNotifyEvent;
  protected      { Protected declarations }
    procedure      KeyPress(var Key: Char); override;
    procedure      Change; override;
  public         { Public declarations }
  published      { Published declarations }
  end;

  TComboMonth = class(TComboBox)
  private        { Private declarations }
  protected      { Protected declarations }
    procedure      CloseUp; override;
  public         { Public declarations }
  published      { Published declarations }
  end;

  TComboDay = class(TComboBox)
  private        { Private declarations }
  protected      { Protected declarations }
    procedure    CloseUp; override;
  public         { Public declarations }
  published      { Published declarations }
  end;

  TeCalendar = class(TPanel)
  private        { Private declarations }
    FCalendar:     TeCustomCalendar;
    FEditYear:     TeEdit;
    FComboMonth:   TComboMonth;
    FComboDay:     TComboDay;
    procedure      SetCalendar(const Value: TeCustomCalendar);
    procedure      SetYear(const Value: TeEdit);
    procedure      SetMonth(const Value: TComboMonth);
    procedure      SetDay(const Value: TComboDay);
  protected      { Protected declarations }
  public         { Public declarations }
    constructor  Create(AOwner: TComponent); override;
    procedure    Paint; override;
    function     IsLeapYear(AYear: Integer): Boolean;
    function     DaysPerMonth(AYear, AMonth: Integer): Integer;
    function     DaysThisMonth: Integer;
    destructor   Destroy; override;
  published      { Published declarations }
    property     Calendar:   TeCustomCalendar  read FCalendar   write SetCalendar;
    property     EditYear:   TeEdit      read FEditYear   write SetYear;
    property     ComboMonth: TComboMonth read FComboMonth write SetMonth;
    property     ComboDay:   TComboDay   read FComboDay   write SetDay;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('EOSoft', [TeCalendar]);
end;

procedure TeCustomCalendar.Click;
begin
  inherited Click;
  (Parent as TeCalendar).FComboDay.ItemIndex := Day-1;
end;

procedure TeEdit.Change;
var
  I:                   Integer;
  L:                   LongInt;
begin
  inherited Change;
  Val(Text, L, I);
  (Parent as TeCalendar).Calendar.Year := L;
end;

procedure TeEdit.KeyPress(var Key: Char);
begin
  inherited;
  if Assigned(FKeyPress) then
    FKeyPress(Self);
  if not (Key in ['0'..'9', #8]) then
    Key := #0;
end;

procedure TComboMonth.CloseUp;
begin
  inherited CloseUp;
  (Parent as TeCalendar).Calendar.Month := Integer(Items.Objects[ItemIndex]);
end;

procedure TComboDay.CloseUp;
begin
  inherited CloseUp;
  (Parent as TeCalendar).Calendar.Day := Integer(Items.Objects[ItemIndex]);
end;

constructor TeCalendar.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Width := 160;
  Height := 144;
  Caption := '';

  FCalendar := TeCustomCalendar.Create(Self);
  FCalendar.Parent := Self as TWinControl;
  FCalendar.SetSubComponent(True);
  FCalendar.Name := 'Calendar';
  FCalendar.Top := 20;
  FCalendar.Left := 2;
  FCalendar.Width := 156;
  FCalendar.Height := 128;

  FEditYear := TeEdit.Create(Self);
  FEditYear.Parent := Self as TWinControl;
  FEditYear.SetSubComponent(True);
  FEditYear.Name := 'EditY';
  FEditYear.Top := 1;
  FEditYear.Left := 2;
  FEditYear.Width := 48;

  FComboMonth := TComboMonth.Create(Self);
  FComboMonth.Parent := Self as TWinControl;
  FComboMonth.SetSubComponent(True);
  FComboMonth.Name := 'ComboM';
  FComboMonth.Text := '';
  FComboMonth.Top := 1;
  FComboMonth.Left := 50;
  FComboMonth.Width := 64;
  FComboMonth.Style := csDropDownList;
  FComboMonth.DropDownCount := 12;

  FComboDay := TComboDay.Create(Self);
  FComboDay.Parent := Self as TWinControl;
  FComboDay.SetSubComponent(True);
  FComboDay.Name := 'ComboD';
  FComboDay.Text := '';
  FComboDay.Top := 1;
  FComboDay.Left := 112;
  FComboDay.Width := 40;
  FComboDay.Style := csDropDownList;
  FComboDay.DropDownCount := 31;

  RePaint;
end;

procedure TeCalendar.Paint;
var
  I:        Integer;
begin
  inherited;
  FEditYear.Text := IntToStr(Calendar.Year);
  FComboMonth.Clear;
  for I:= 1 to 12 do
    FComboMonth.Items.AddObject(ShortMonthNames[I], TObject(I));
  FComboMonth.ItemIndex := Calendar.Month-1;
  FComboDay.Clear;
  for I:= 1 to DaysThisMonth do
    FComboDay.Items.AddObject(IntToStr(I), TObject(I));
  FComboDay.ItemIndex := Calendar.Day-1;
end;

procedure TeCalendar.SetCalendar(const Value: TeCustomCalendar);
begin
  FCalendar.Assign(Value);
  Invalidate;
end;

procedure TeCalendar.SetYear(const Value: TeEdit);
begin
  FEditYear.Assign(Value);
  Invalidate;
end;

procedure TeCalendar.SetMonth(const Value: TComboMonth);
begin
  FComboMonth.Assign(Value);
  Invalidate;
end;

procedure TeCalendar.SetDay(const Value: TComboDay);
begin
  FComboDay.Assign(Value);
  Invalidate;
end;

destructor  TeCalendar.Destroy;
begin
  if Assigned(Calendar) then
    Calendar.Destroy;
  if Assigned(EditYear) then
    EditYear.Destroy;
  if Assigned(ComboMonth) then
    ComboMonth.Destroy;
  if Assigned(ComboDay) then
    ComboDay.Destroy;
  inherited Destroy;
end;

function TeCalendar.IsLeapYear(AYear: Integer): Boolean;
begin
  Result := (AYear mod 4 = 0) and ((AYear mod 100 <> 0) or (AYear mod 400 = 0));
end;

function TeCalendar.DaysPerMonth(AYear, AMonth: Integer): Integer;
const
  DaysInMonth: array[1..12] of Integer = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
begin
  Result := DaysInMonth[AMonth];
  if (AMonth = 2) and IsLeapYear(AYear) then Inc(Result); { leap-year Feb is special }
end;

function TeCalendar.DaysThisMonth: Integer;
begin
  Result := DaysPerMonth(Calendar.Year, Calendar.Month);
end;

initialization
  ShortDayNames[1] := 'Mo';
  ShortDayNames[2] := 'Tu';
  ShortDayNames[3] := 'We';
  ShortDayNames[4] := 'Th';
  ShortDayNames[5] := 'Fr';
  ShortDayNames[6] := 'Sa';
  ShortDayNames[7] := 'Su';

end.

emil
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10698983
or try this
http://delphi.icm.edu.pl/ftp/d10free/dlcomponents.zip
Has calendar component unlike borland's
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now