Solved

calendar component for application

Posted on 2004-03-21
9
435 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 151
Delphi 2 69
update joined tables 2 55
DBCtrlGrid, Delphi, Scroll 8 38
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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