datainput.cpp

来自「关于书籍《Borland c++Builder工程实践》的源代码」· C++ 代码 · 共 61 行

CPP
61
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "DataInput.h"
#include "result.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDataInputForm *DataInputForm;
//---------------------------------------------------------------------------
__fastcall TDataInputForm::TDataInputForm(TComponent* Owner)
    : TForm(Owner)
{
    InputErrorTime=0;
}
//---------------------------------------------------------------------------
void __fastcall TDataInputForm::BitBtn2Click(TObject *Sender)
{
    if(InputErrorTime>=3)
    {
        MessageDlg("对不起,您的输入错误次数太多,\n请核实后再查询,谢谢!",
                    mtError,TMsgDlgButtons()<<mbOK,0);
        Close();
    }
    TResultForm *ResultForm=new TResultForm(NULL);
    ResultForm->SetAccNo(Edit1->Text);
    ResultForm->SetName(Edit2->Text);
    if ( ResultForm->ShowModal()==mrOk || ResultForm->GetAbortFlag() )
    {
        delete  ResultForm;
        Close();
    }
    else 
    {
        if(ResultForm->GetInputError()) InputErrorTime++;
        delete  ResultForm;
    }
}
//---------------------------------------------------------------------------
void __fastcall TDataInputForm::BitBtn3Click(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------
void __fastcall TDataInputForm::Edit2KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==VK_RETURN)    BitBtn1Click(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TDataInputForm::BitBtn1Click(TObject *Sender)
{
    Edit1->Text="";
    Edit2->Text="";
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?