1 (edited by prahousefamily 2015-07-06 07:35:39)

Topic: How To Add Clock In Form

how to edit script for display clock in footer
and update time every second . . .
http://www.delphicoding.com/images/mgDigiTimer.jpg

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Add Clock In Form

Hello Prahousefamily

Please this code :

var                    // Variables à déclarer en en-tête avant les procédures
   Timer: TTimer;

procedure Form1_OnShow (Sender: string; Action: string);    // Initialisation de l'heure système
begin
     Timer := TTimer.Create (nil);
     Timer.OnTimer := @OnTimer;
     Timer.Interval := 1000;
     Timer.Enabled := True;

end;

procedure OnTimer;
begin
     Form1.Label1.Caption := FormatDateTime('c', Now);                                    // Affichage de l'heure dans le composant Label
end;

procedure Form1_OnClose (Sender: string; Action: string);                     // On libère le composant Timer
begin
     Timer.Free;
end;

Why put it in a footer ?
Here, my code places hour in a label in the bottom of the form

JB

Re: How To Add Clock In Form

It have not effect  !

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Add Clock In Form

Please download an example:
http://myvisualdatabase.com/forum/misc. … download=1

Dmitry.

Re: How To Add Clock In Form

I was having a look at Dmitry's clock sample app. It showed date and time together. Played with it a bit as a learning exercise to show date and time separately. Ended up with this digital clock:
https://s17.postimg.org/5btjzf4wf/zzzzz_Temp6.png


I guess making an analog clock is not that easy. Perhaps somebody can take on the challenge to make a nice looking analog clock?

Post's attachments

Attachment icon Clock - Date and Time LIVE.zip 3.67 kb, 595 downloads since 2017-03-02 

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

AD1408


Please download latest beta version
https://www.dropbox.com/s/xf20ksdbdgj6w … b.zip?dl=0


Then you can use this example to draw analog clock

Post's attachments

Attachment icon Analog Clock.zip 8.1 kb, 579 downloads since 2017-03-08 

Dmitry.

Re: How To Add Clock In Form

Thanks a lot Dmitry.............


Script is beyond me in most parts. How can I change clock face, size, use numbers such as 9-3 12-6 or IX-III XII-VI etc. instead of o? And resizing pens length according to clock face?

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

AD1408 wrote:

Thanks a lot Dmitry.............


Script is beyond me in most parts. How can I change clock face, size, use numbers such as 9-3 12-6 or IX-III XII-VI etc. instead of o? And resizing pens length according to clock face?

Please download the example again, from my previous post.


line 2 in script to change clock size

  R = 75 ;    // radius of clock  
Dmitry.

Re: How To Add Clock In Form

Great stuff Dmitry!!!
Thank you very much.................


You put the numbers outside the minutes ellipse, that's nice... I couldn't find a way to customize newly added numbers such as their distance from minutes ellipse, changing font size, font color, using less numbers and using different fonts?

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

AD1408 wrote:

... I couldn't find a way to customize newly added numbers such as their distance from minutes ellipse, changing font size, font color, using less numbers and using different fonts?


Hi Dmitry,
Are above complicated and requires too much of your time?

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

In the section const I have added some params to customize clock

const
  R = 70;    // radius of clock
  RN = 85;  // radius of numbers
  color_clock = clBlack;
  color_numbers = clBlack;
  numbers_font = 'Arial';
  numbers_size = 10;

Please download the example again
http://myvisualdatabase.com/forum/viewt … 279#p19279

Dmitry.

Re: How To Add Clock In Form

Hi Dmitry,


Thank you very much...................
Great stuff...... Appreciated.


Next step would would be to have multiple clocks for different locations around the world beside the local time. For this I guess app needs to connect to Internet to get specific location time.


I hope I'm not asking too much. You have been very kind and providing GREAT help and support.

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

Hi Adam,
Not sure if I'm misunderstanding you about the clock.  Why do you need to go onto the internet to get specific location times - can't you just work it out as plus N hours or minus N hours offset from your PC's own clock?
Example is attached (for maximum flexibility, you can select your own locations (up to 24), the time zone offsets etc etc by clicking on the 'SETUP' button).  I appreciate it's just a digital clock (rather than the analogue one) but the principle is identical if you want to make use of it.
Regards,
Derek.

Post's attachments

Attachment icon adam24hour.zip 340.96 kb, 550 downloads since 2017-03-09 

14 (edited by AD1408 2017-03-09 13:08:58)

Re: How To Add Clock In Form

Hi Derek,


Thanks a lot for the sample project............................


It's fine using PC clock as a base. It'd be much more easier for a user if getting time is automated. That's why I was hoping to get time from the web. By the way I couldn't find how you displayed labels from 2 to 24 so that I can customize and add more clocks?
EDIT: I have found labels, you have used a blank characters for each label except label 1. Therefore customizing and adding more clocks resolved.


The following makes all clocks live which I wanted:

var
   Timer: TTimer;

procedure formwtz_OnShow (Sender: string; Action: string);
begin
     Timer := TTimer.Create (nil);
     Timer.OnTimer := @OnTimer;
     Timer.Interval := 1000;
     Timer.Enabled := True;
end;

procedure OnTimer;
begin
  //Form1.Label1.Caption := FormatDateTime('c', Now);  //Shows date and time together
  formwtz.label25.Caption := FormatDateTime('ddd dd mmm yyyy', Now); // Shows date: Wed 01 Mar 2017 depending on comp date display settings
  //Form1.Label2.Caption := FormatDateTime('t:s', Now); //Shows clock only with hour minutes and seconds
  //formwtz.Label26.Caption := FormatDateTime('hh : mm : ss', Now); //Shows clock only with hour minutes and seconds
  formwtz.label26.caption := 'Local Time is:  ' +FormatDateTime('hh : mm : ss', Now);

  formwtz.label1.Caption  := sqlexecute('select city from ctz where labelno = "01"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "01"')/24));
  formwtz.label2.Caption  := sqlexecute('select city from ctz where labelno = "02"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "02"')/24));
  formwtz.label3.Caption  := sqlexecute('select city from ctz where labelno = "03"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "03"')/24));
  formwtz.label4.Caption  := sqlexecute('select city from ctz where labelno = "04"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "04"')/24));
  formwtz.label5.Caption  := sqlexecute('select city from ctz where labelno = "05"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "05"')/24));
  formwtz.label6.Caption  := sqlexecute('select city from ctz where labelno = "06"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "06"')/24));
  formwtz.label7.Caption  := sqlexecute('select city from ctz where labelno = "07"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "07"')/24));
  formwtz.label8.Caption  := sqlexecute('select city from ctz where labelno = "08"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "08"')/24));
  formwtz.label9.Caption  := sqlexecute('select city from ctz where labelno = "09"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "09"')/24));
  formwtz.label10.Caption := sqlexecute('select city from ctz where labelno = "10"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "10"')/24));
  formwtz.label11.Caption := sqlexecute('select city from ctz where labelno = "11"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "11"')/24));
  formwtz.label12.Caption := sqlexecute('select city from ctz where labelno = "12"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "12"')/24));
  formwtz.label13.Caption := sqlexecute('select city from ctz where labelno = "13"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "13"')/24));
  formwtz.label14.Caption := sqlexecute('select city from ctz where labelno = "14"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "14"')/24));
  formwtz.label15.Caption := sqlexecute('select city from ctz where labelno = "15"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "15"')/24));
  formwtz.label16.Caption := sqlexecute('select city from ctz where labelno = "16"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "16"')/24));
  formwtz.label17.Caption := sqlexecute('select city from ctz where labelno = "17"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "17"')/24));
  formwtz.label18.Caption := sqlexecute('select city from ctz where labelno = "18"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "18"')/24));
  formwtz.label19.Caption := sqlexecute('select city from ctz where labelno = "19"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "19"')/24));
  formwtz.label20.Caption := sqlexecute('select city from ctz where labelno = "20"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "20"')/24));
  formwtz.label21.Caption := sqlexecute('select city from ctz where labelno = "21"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "21"')/24));
  formwtz.label22.Caption := sqlexecute('select city from ctz where labelno = "22"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "22"')/24));
  formwtz.label23.Caption := sqlexecute('select city from ctz where labelno = "23"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "23"')/24));
  formwtz.label24.Caption := sqlexecute('select city from ctz where labelno = "24"')+':  '+timetostr(time+(sqlexecute('select pm from ctz where labelno = "24"')/24));
end;

procedure formwtz_OnClose (Sender: string; Action: string);
begin
     Timer.Free;
end;

I have tried analog clocks version but couldn't........
Could you possible change 2 of the 24 clocks to analog clocks so that we can have combination of digital and analog clocks on same form please - Live version as in the code above?

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

I put 1 analog clock for local but couldn't add another one that works in this case for Honolulu..


https://s15.postimg.org/lqsl8zh1n/zzzzz_Temp7.png


When adding second analog clock, I couldn't prevent handles repainting.


Please see the attached sample project:

Post's attachments

Attachment icon Clocks - Derek LT for multi clocks + Analog TEST.zip 18.35 kb, 507 downloads since 2017-03-10 

Adam
God... please help me become the person my dog thinks I am.

Re: How To Add Clock In Form

Hello.


Fixed project.
Also I have added possibility to change offset of clock in minutes.

Post's attachments

Attachment icon Clocks - Derek LT for multi clocks + Analog TEST_fixed.zip 17.91 kb, 569 downloads since 2017-03-13 

Dmitry.

Re: How To Add Clock In Form

Hi Dmitry,


Thank you very much.............................
Great stuff as usual...... Appreciated very much........

Adam
God... please help me become the person my dog thinks I am.