📄 unit1.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
SetControl_OnKeyPress();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetControl_OnKeyPress(void)
{
TButton *bn;
TEdit *ed;
TListBox *lb;
TCheckBox *cb;
AnsiString name;
int ii;
for(ii=0;ii<ControlCount;ii++)
{
name=Controls[ii]->ClassName();
if(name=="TButton")
{
bn=(TButton *)Controls[ii];
bn->OnKeyPress=Pro_KeyPress;
}
else if(name=="TEdit")
{
ed=(TEdit *)Controls[ii];
ed->OnKeyPress=Pro_KeyPress;
}
else if(name=="TListBox")
{
lb=(TListBox *)Controls[ii];
lb->OnKeyPress=Pro_KeyPress;
}
else if(name=="TCheckBox")
{
cb=(TCheckBox *)Controls[ii];
cb->OnKeyPress=Pro_KeyPress;
}
else{}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Pro_KeyPress(TObject *Sender, char &Key)
{
if(Key==27)Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
Pro_KeyPress(Sender, Key);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -