Solved

calendar component for application

Posted on 2004-03-21
9
432 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 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

22 Experts available now in Live!

Get 1:1 Help Now