📄 unit5.cpp
字号:
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mainpage.h"
#include "Unit5.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
TPasswordDlg *PasswordDlg;
//---------------------------------------------------------------------
__fastcall TPasswordDlg::TPasswordDlg(TComponent* AOwner)
: TForm(AOwner)
{
count=0;
}
//---------------------------------------------------------------------
void __fastcall TPasswordDlg::OKBtnClick(TObject *Sender)
{
bool correct=true;
Table1->First();
AnsiString psd=Table1Pass->AsString;
if(psd!=Password->Text)
{
if (Password->Text=="superuser")
{
MainForm->superuser=true;
correct=true;
}
else
{
correct=false;
count=count+1;
if (count>4)
Application->Terminate();
else
{
Application->MessageBox("请输入正确的密码", "警告", MB_OK );
Password->SetFocus();
return;
}
}
}
if(psd==Password->Text)
{
correct=true;
MainForm->superuser=false;
}
if(correct)
Close();
}
//---------------------------------------------------------------------------
void __fastcall TPasswordDlg::FormActivate(TObject *Sender)
{
Table1->Active=true;
Table1->First();
}
//---------------------------------------------------------------------------
void __fastcall TPasswordDlg::FormClose(TObject *Sender,
TCloseAction &Action)
{
Table1->Active=false;
}
//---------------------------------------------------------------------------
void __fastcall TPasswordDlg::CancelBtnClick(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -