w podświetlonych liniach i nie tylko jeszcze z kolorami
148 , 142
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGRID"
#pragma link "CSPIN"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int s=15; ///////CZAS///////////////////////////////////
String h="0";
String min="0";
String sec="0";
int pomoc;
int plik=0;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (h !="" && min!="" && sec!="")
{
h=Edit2->Text;
min=Edit3->Text;
sec=Edit4->Text;
int a,b,c, time;
a=h.ToInt();
b=min.ToInt();
c=sec.ToInt();
time=a*3600+b*60+c; //a*3600+b*60+
s=time;
Timer1->Enabled=true;
pomoc= time/100;
ProgressBar1->Min = 0;
ProgressBar1->Max = time;
ProgressBar1->Position = 0;
//ProgressBar1->Position = 50;
Button1->Visible=false;
wyl->Visible=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
//ZAMIENIANIE INTA NA STRINGA (by mógł by przedstawiony jako CAption)
s--;
int godzin, minut, sekund;
AnsiString godz, min, sek;
godzin = s / 3600;
godz= IntToStr(godzin); //zamień inta na stringa
if(godzin<10) godz="0"+godz;//by dodac 0 z przodu
minut =(s - godzin * 3600) / 60;
min= IntToStr(minut); //zamień inta na stringa
if(minut<10) min="0"+min;//by dodac 0 z przodu
sekund = s- godzin* 3600 - minut*60;
sek= IntToStr(sekund); //zamień inta na stringa
if(sekund<10) sek="0"+sek;//by dodac 0 z przodu
Label1->Caption = godz+":"+min+":"+sek;
ProgressBar1->Position ++;
if (s<=0)
{
Label1->Caption="Koniec czasu!";
Button1->Visible=true;
wyl->Caption="STOP";
Timer1->Enabled= false;
if( plik == 0 )
{
MediaPlayer1->FileName = "music/A1.mp3";
//MediaPlayer1->FileName = "snd/dzwiek.wav";
}
else
{
MediaPlayer1->FileName = OpenDialog1->FileName;
}
MediaPlayer1->Open();
MediaPlayer1->Play();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
//////////////////KONTROLA WPISYWANIA- SAME LICZBY////////////////////////////////////
if (!(isdigit(Key) || Key == VK_BACK || Key == DecimalSeparator || Key==45))
{
Key = 0;
}
else
{
if ((Key == DecimalSeparator) && (Edit1->Text.Pos(DecimalSeparator) > 0))
{
Key = 0;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Shape1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
//Form1->Color =RGB(rand()%255, rand()%255, rand()%255);
Form1->Color = clMoneyGreen;
Form1->Font->Color = clNone;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Shape2MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Form1->Color =clDefault;
Form1->Font->Color = clWindow;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Shape3MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Form1->Color =RGB(rand()%255, rand()%255, rand()%255);
}
int wl;
//---------------------------------------------------------------------------
void __fastcall TForm1::wylClick(TObject *Sender)
{
if(wl==0)
{
Timer1->Enabled=false;
Button1->Visible=true;
wyl->Caption="WZNÓW";
wl=1;
MediaPlayer1->Stop();
MediaPlayer1->Close();
}
else
{
Timer1->Enabled=true;
wyl->Caption="ZATRZYMAJ";
wl=0;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
wyl->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
OpenDialog1->Execute();
if(OpenDialog1->Execute()){
MediaPlayer1->FileName = OpenDialog1->FileName;
MediaPlayer1->Open();
plik=1;
}
}
//---------------------------------------------------------------------------