?
Solved

calendar component for application

Posted on 2004-03-21
9
Medium Priority
?
457 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
6 Comments
 
LVL 17

Accepted Solution

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

Assisted Solution

by:shaneholmes
shaneholmes earned 164 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 164 total points
ID: 10647027
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
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 164 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…

584 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