Solved

calendar component for application

Posted on 2004-03-21
9
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
Delphi Firemonkey Need Sample for Online Shopping Example. 2 218
delphi parse string to params 3 179
Tidtcpserver listening on multiports? 1 56
Wincontrol not (correctly) drawn 15 59
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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