1 (edited by livexox 2017-11-16 23:44:52)

Topic: Big Calendar Sample

Here is a sample of a project that generates a big calendar view. There a probably many ways of generating a calendar, this is just one way.  Hope this helps someone.

Post's attachments

Attachment icon BigCalendar.zip 355.28 kb, 569 downloads since 2017-11-17 

Re: Big Calendar Sample

Hello.


Thank you for the example.


It's not good idea to use StrToDate in the example, because another machine may have different date format.


Check it out

procedure frm_Main_Show (Sender: string; var Cancel: String);
var
    DaysInCurrentMonth, FirstDayOfWeek, CurrentDay, CurrentMonth,CurrentYear, i: int;
    FirstOfTheMonth, LastOfTheMonth: date;
    DD, MM, YY: word;
begin
    DecodeDate(frm_Main.main_calendar.Date, YY, MM, DD);
    DaysInCurrentMonth := DaysInMonth(YY, MM);
    CurrentDay :=  DD;
    CurrentMonth :=  MM;
    CurrentYear := YY;

    FirstOfTheMonth := EncodeDate(YY, MM, 1);
    LastOfTheMonth := EncodeDate(YY, MM, DaysInCurrentMonth);
    FirstDayOfWeek := DayOfWeek(FirstOfTheMonth);

    frm_Main.fld_day.Caption :=Formatdatetime('mm/dd/yyyy',frm_Main.main_calendar.Date);
    frm_main.DaysInCurrentMonth.Caption :=  IntToStr(DaysInCurrentMonth);
    frm_Main.fld_CurrentMonth.Caption := Formatdatetime('mmmm',frm_Main.main_calendar.Date)+ ' ' + Formatdatetime('yyyy',frm_Main.main_calendar.Date);

    //generate big calendar
    BigCalendar('',FirstDayOfWeek,CurrentMonth, CurrentYear, DaysInCurrentMonth);

end;
Dmitry.