Apagar/Apagar.cpp
2021-09-12 21:55:59 +02:00

57 lines
1.9 KiB
C++

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Apagar.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if ( CheckBox1->Checked )
{
TDateTime hm = TDateTime::CurrentTime();
unsigned short h, m, s, ss;
hm.DecodeTime( &h, &m, &s, &ss );
if ( h == Edit1->Text.ToInt() && m >= Edit2->Text.ToInt() )
{
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE | EWX_POWEROFF, 0))
{
ShowMessage( "Error Cerrando el EQUIPO\nIntente cierre manual" );
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2Change(TObject *Sender)
{
try {
if ( Edit2->Text.ToInt() < 0 || Edit2->Text.ToInt() >59 ) Edit2->Text = "0";
} catch(...) { Edit2->Text = "0";
Edit2->SelStart= 0;
Edit2->SelLength= 1;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
try {
if ( Edit1->Text.ToInt() < 0 || Edit1->Text.ToInt() > 23 ) Edit1->Text = "0";
} catch(...) { Edit1->Text = "0";
Edit1->SelStart= 0;
Edit1->SelLength= 1;
}
}
//---------------------------------------------------------------------------