Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <stdlib.h>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "CSPIN"
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13.         : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::UpDn(bool up,TEdit *Ed)
  18. {
  19.   double aa;
  20.   if(up)
  21.   {
  22.     aa=GetNumFromEdit(Ed);
  23.     aa=aa+0.1;
  24.     if(aa>100)aa=100;
  25.     Ed->Text=FloatToStr(aa)+"厘米";
  26.   }
  27.   else
  28.   {
  29.     aa=GetNumFromEdit(Ed);
  30.     aa=aa-0.1;
  31.     if(aa<0)aa=0;
  32.     Ed->Text=FloatToStr(aa)+"厘米";
  33.   }
  34. }
  35. //---------------------------------------------------------------------------
  36. double __fastcall TForm1::GetNumFromEdit(TEdit *Ed)
  37. {
  38.   double aa;
  39.   aa=atof(Ed->Text.c_str());
  40.   return aa;
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::CSpinButton3DownClick(TObject *Sender)
  44. {
  45.   UpDn(False,EdLeft);
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TForm1::CSpinButton3UpClick(TObject *Sender)
  49. {
  50.   UpDn(True,EdLeft);
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TForm1::CSpinButton5DownClick(TObject *Sender)
  54. {
  55.   UpDn(False,EdRight);
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TForm1::CSpinButton5UpClick(TObject *Sender)
  59. {
  60.   UpDn(True,EdRight);
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TForm1::CSpinButton4DownClick(TObject *Sender)
  64. {
  65.   UpDn(False,EdTop);
  66. }
  67. //---------------------------------------------------------------------------
  68. void __fastcall TForm1::CSpinButton4UpClick(TObject *Sender)
  69. {
  70.   UpDn(True,EdTop);
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::CSpinButton6DownClick(TObject *Sender)
  74. {
  75.   UpDn(False,EdBottom);
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TForm1::CSpinButton6UpClick(TObject *Sender)
  79. {
  80.   UpDn(True,EdBottom);
  81. }
  82. //---------------------------------------------------------------------------