Ejemplo n.º 1
0
//---------------------------------------------------------------------------
void __fastcall TClockDlg::ClockEditChange( TObject *Sender )
{
   if ( initialised )
   {
      TEMPBUFF( instr, 20 );

      time_t cttime = time( 0 );			// computer time
      struct tm *tms = localtime( &cttime );  // NB static data area!

      struct tm tmstr;
      tmstr = *tms;	// overwrite it

      tmstr.tm_mday = DayEdit->Text.ToIntDef( 0 );
      tmstr.tm_mon = MonthEdit->Text.ToIntDef( 0 ) - 1;
      tmstr.tm_year = YearEdit->Text.ToIntDef( 1900 ) - 1900;

      time_t cttime2 = mktime( &tmstr );	// time value for the day

      // now we need to make that into a correction value

      long date_correction = cttime2 - cttime;	// I hope sign is right!

      long clock_correction = HoursEdit->Text.ToIntDef( 0 ) * 3600;
      clock_correction += MinutesEdit->Text.ToIntDef( 0 ) * 60;
      clock_correction += SecondsEdit->Text.ToIntDef( 0 );

      correction = ( clock_correction + date_correction ) / dtg::daySecs;

      Timer1Timer( Sender );
   }
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
        zerujsily();
        if (CheckBox1->Checked)
                if (!aktualizujpolozenia())
                        Timer1Timer(Sender);
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
void __fastcall TClockDlg::ApplyButtonClick( TObject *Sender )
{
   setEdits();
   bigClockCorr = correction;
   Timer1Timer( Sender );
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TClockDlg::ClearButtonClick( TObject *Sender )
{
   correction = 0;
   setEdits();
   Timer1Timer( Sender );
}