Recent

Author Topic: [solved] Tcalendar  (Read 4310 times)

zoimutante

  • New Member
  • *
  • Posts: 34
[solved] Tcalendar
« on: December 20, 2016, 04:53:02 am »
I cant make tcalendar to show current time and date.
Any help ?
« Last Edit: December 20, 2016, 08:42:14 pm by zoimutante »

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Tcalendar
« Reply #1 on: December 20, 2016, 09:01:13 am »
Code: Pascal  [Select][+][-]
  1. Calender1.DateTime := Now;
  2.  

But the calender sets the correct time itself from the system clock and the locale settings, so that should not be necessary.
To show the time you need an extra bit of work.
« Last Edit: December 20, 2016, 09:05:56 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

ASerge

  • Hero Member
  • *****
  • Posts: 2469
Re: Tcalendar
« Reply #2 on: December 20, 2016, 03:41:42 pm »
But the calender sets the correct time itself from the system clock and the locale settings, so that should not be necessary.
The first is true but the second not, because the DateTime property is replaced with the value saved at design time. So, the code above needed at FormCreate.

I cant make tcalendar to show current time and date.
The calendar is used for date selection only. If need both, use TDateTimePicker with .Kind = dtkDateTime.

zoimutante

  • New Member
  • *
  • Posts: 34
Re: Tcalendar
« Reply #3 on: December 20, 2016, 05:13:41 pm »
I make a mistake, i don't need tcalendar to show time, only date it self.
Any other question: Tcalendar wiht the code abve will update the date even when date it changes on system with out restart app ?or i need a loop to constant update it ?
thanks both
« Last Edit: December 20, 2016, 05:22:22 pm by zoimutante »

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Tcalendar
« Reply #4 on: December 20, 2016, 05:24:37 pm »
No.Update it periodically with a TTimer or the OnIdle event of TApplication.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

zoimutante

  • New Member
  • *
  • Posts: 34
Re: Tcalendar
« Reply #5 on: December 20, 2016, 05:27:14 pm »
how to edit the title to mark as solved?

zoimutante

  • New Member
  • *
  • Posts: 34
Re: Tcalendar
« Reply #6 on: December 20, 2016, 05:42:12 pm »
No.Update it periodically with a TTimer or the OnIdle event of TApplication.

where is OnIdle event of TApplication. ?

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Tcalendar
« Reply #7 on: December 20, 2016, 05:59:14 pm »
http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplication.onidle.html

It helps if you start reading the excellent documentation before asking a question here.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

zoimutante

  • New Member
  • *
  • Posts: 34
Re: Tcalendar
« Reply #8 on: December 20, 2016, 06:51:45 pm »
http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplication.onidle.html

It helps if you start reading the excellent documentation before asking a question here.

Sir, I can bet my life that I read documentation. The problem is, I'm new to this thing named lazarus, I fail in basics concepts, If I needed a simple date, I would simple use pascal and show date on the text of an edit or even a button. but i dont know how to this with tcalendar... even after reading the documantation

zoimutante

  • New Member
  • *
  • Posts: 34
Re: Tcalendar
« Reply #9 on: December 20, 2016, 07:28:23 pm »
Solution with fellows help.

On the on change proprety, use this code

procedure TForm1.Calendar1Change(Sender: TObject);
begin
  Calendar1.DateTime:=now;         

On OnCreate event  did the same, now calendar is stick with current system data

thank you all

 

TinyPortal © 2005-2018