segunda-feira, 25 de maio de 2020

C++ Builder - Relógio digital

Já que criamos um relógio digital
em eletrônica com proteus,
outro em Linguagem C,
com saída no console do windows, 
outro com a biblioteca graphics.h,
outro usando linguagem java,
e outro usando o JavaFx, o que poderia impedir
de criarmos um usando o C++ Builder?
Aqui está funcionando no vídeo 
um relógio digital criado no C++ Builder,
e em nada ficou em falta.




//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer ( TObject *Sender ) {
if ( horas < 10 )
Label1 -> Caption = "0";
if ( horas == 24 ) {
Label1 -> Left = 90;
horas = 0;
Label1 -> Caption = "0";
}
Label1 -> Caption = Label1 -> Caption + StrToInt ( horas );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer2Timer ( TObject *Sender ) {
if ( inicia_minutos == true ) {
minutos++;
}
if ( minutos < 10 ) {
Label2 -> Caption = "0";
}
if ( minutos == 60 ) {
minutos = 0;
horas++;
Label2 -> Caption = "0";
}
if ( ( minutos >= 10 && minutos < 60 ) )
Label2 -> Caption = StrToInt ( minutos );

if ( ( minutos >= 20 && minutos < 60 ) ){
Label2 -> Caption = StrToInt ( minutos );
Label2 -> Caption = Label2 -> Caption + " ";
}

Label2 -> Caption = Label2 -> Caption + StrToInt ( minutos );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer3Timer ( TObject *Sender ) {
if ( inicia_segundos == true ) {
segundos++;
}
if ( segundos < 10 ) {
Label3 -> Caption = "0";
}
if ( segundos == 60 ) {
segundos = 0;
        minutos++;
Label3 -> Caption = "0";
}
if ( ( segundos >= 10 && segundos < 60 ) )
Label3 -> Caption = StrToInt ( segundos );

if ( ( segundos >= 20 && segundos < 60 ) ){
Label3 -> Caption = StrToInt ( segundos );
Label3 -> Caption = Label3 -> Caption + " ";
}

Label3 -> Caption = Label3 -> Caption + StrToInt ( segundos );
}
//---------------------------------------------------------------------------



Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.