Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <stdlib.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "CSPIN"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::UpDn(bool up,TEdit *Ed)
- {
- double aa;
- if(up)
- {
- aa=GetNumFromEdit(Ed);
- aa=aa+0.1;
- if(aa>100)aa=100;
- Ed->Text=FloatToStr(aa)+"厘米";
- }
- else
- {
- aa=GetNumFromEdit(Ed);
- aa=aa-0.1;
- if(aa<0)aa=0;
- Ed->Text=FloatToStr(aa)+"厘米";
- }
- }
- //---------------------------------------------------------------------------
- double __fastcall TForm1::GetNumFromEdit(TEdit *Ed)
- {
- double aa;
- aa=atof(Ed->Text.c_str());
- return aa;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton3DownClick(TObject *Sender)
- {
- UpDn(False,EdLeft);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton3UpClick(TObject *Sender)
- {
- UpDn(True,EdLeft);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton5DownClick(TObject *Sender)
- {
- UpDn(False,EdRight);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton5UpClick(TObject *Sender)
- {
- UpDn(True,EdRight);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton4DownClick(TObject *Sender)
- {
- UpDn(False,EdTop);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton4UpClick(TObject *Sender)
- {
- UpDn(True,EdTop);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton6DownClick(TObject *Sender)
- {
- UpDn(False,EdBottom);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton6UpClick(TObject *Sender)
- {
- UpDn(True,EdBottom);
- }
- //---------------------------------------------------------------------------