?? unit1.cpp
字號(hào):
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
SetCons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
TDateTime dd;
if(CloseMode==0)
{
NN++;
Label1->Caption=IntToStr(NN);
if(NN>=10)Close();
}
else if(CloseMode==1)
{
dd=Now().CurrentTime();
Label1->Caption=dd.TimeString();
if(dd>=defTime)Close();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Interval=500;
Timer1->Enabled=True;
CloseMode=0;
NN=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
AnsiString ss =Now().TimeString();
InputQuery("輸入指定時(shí)間","提示",ss);
try
{
defTime=StrToTime(ss);
Timer1->Interval=1000;
Timer1->Enabled=True;
CloseMode=1;
}
catch(...)
{
Application->MessageBox("時(shí)間輸入錯(cuò)誤!","提示",MB_OK);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ConKeyPress(TObject *Sender, char &Key)
{
NN=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ConMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
NN=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetCons(void)
{
TEdit *ed;
TButton *bn;
TCheckBox *cb;
TRadioButton *rb;
int ii;
AnsiString name;
for(ii=0;ii<ControlCount;ii++)
{
name=Controls[ii]->ClassName();
if(name=="TEdit")
{
ed=(TEdit *)Controls[ii];
ed->OnKeyPress=ConKeyPress;
ed->OnMouseMove=ConMouseMove;
}
else if(name=="TButton")
{
bn=(TButton *)Controls[ii];
bn->OnKeyPress=ConKeyPress;
bn->OnMouseMove=ConMouseMove;
}
else if(name=="TCheckBox")
{
cb=(TCheckBox *)Controls[ii];
cb->OnKeyPress=ConKeyPress;
cb->OnMouseMove=ConMouseMove;
}
else if(name=="TRadioButton")
{
rb=(TRadioButton *)Controls[ii];
rb->OnKeyPress=ConKeyPress;
rb->OnMouseMove=ConMouseMove;
}
else
{
}
}
}
//---------------------------------------------------------------------------
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -