-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit1.cpp
93 lines (79 loc) · 2.38 KB
/
Unit1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
short h, m, s;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Form1->Hide();
ShowWindow(Handle,SW_HIDE); // Ñêðûâàåì ïðîãðàììó
ShowWindow(Application->Handle,SW_HIDE); // Ñêðûâàåì êíîïêó ñ TaskBar$$à
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
h = StrToInt( SpinEdit1 -> Text );
m = StrToInt( SpinEdit2 -> Text );
s = StrToInt( SpinEdit3 -> Text );
Timer1 -> Enabled = true;
//WinExec("shutdown -s -t 0", SW_HIDE); // âûêëþ÷åíèå
//WinExec("shutdown -r -t 0", SW_HIDE); // ïåðåçàãðóçêà
//WinExec("shutdown -l -t 0", SW_HIDE); // âûõîä
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if ( s >= 1 )
{s--;}
else if ( s <= 0 )
{s = 59; s--;
if ( m >= 1 )
{m--;}
else if ( m <= 0 )
{m = 59;
if ( h >= 1 )
{h--;}
else if ( s <= 0, m <= 0, h <= 0 )
{
WinExec("shutdown -s -t 0", SW_HIDE);
}}
if (m<1) {
Form2->Show();
Form1->Hide();
}}
Form2->Label1->Caption = IntToStr(s);
SpinEdit1->Text = IntToStr(h);
SpinEdit2->Text = IntToStr(m);
SpinEdit3->Text = IntToStr(s);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{
exit(0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TrayIcon1Click(TObject *Sender)
{
Form1->Visible = true;
Application->Restore();
Form1->FormStyle = fsStayOnTop;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ApplicationEvents1Minimize(TObject *Sender)
{
Application->Minimize();
Form1->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Form1->Timer1->Enabled = false;
}
//---------------------------------------------------------------------------