Week.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:5k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Week.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "CCALENDR"
- #pragma link "CSPIN"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Form1->Edit1->Text="请输入年份";
- Form1->Edit2->Text="请输入月份";
- Form1->Edit3->Text="请输入日期";
- //文本控件的初始化
- Form1->CCalendar1->Year=1977;
- Form1->CCalendar1->Month=1;
- Form1->CCalendar1->Day=19;
- //CCalendar控件的初始化
- Form1->CCalendar1->Enabled=false;
- Form1->Edit1->Enabled=false;
- Form1->Edit2->Enabled=false;
- Form1->Edit3->Enabled=false;
- Form1->CSpinButton1->Enabled=false;
- Form1->CSpinButton2->Enabled=false;
- Form1->CSpinButton3->Enabled=false;
- Form1->Timer1->Enabled=false;
- //设置控件的有效状态
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- Form1->CCalendar1->Enabled=true;
- Form1->Edit1->Enabled=true;
- Form1->Edit2->Enabled=true;
- Form1->Edit3->Enabled=true;
- Form1->CSpinButton1->Enabled=true;
- Form1->CSpinButton2->Enabled=true;
- Form1->CSpinButton3->Enabled=true;
- Form1->Timer1->Enabled=true;
- //设置控件的有效状态
- Form1->CCalendar1->Year=StrToInt(Form1->Edit1->Text);
- Form1->CCalendar1->Month=StrToInt(Form1->Edit2->Text);
- Form1->CCalendar1->Day=StrToInt(Form1->Edit3->Text);
- //查询文本框中显示的日期
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CCalendar1Change(TObject *Sender)
- {
- Form1->Edit1->Text=IntToStr(Form1->CCalendar1->Year);
- Form1->Edit2->Text=IntToStr(Form1->CCalendar1->Month);
- Form1->Edit3->Text=IntToStr(Form1->CCalendar1->Day);
- //在文本框中显示日期信息
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton1DownClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit1->Text)>1)
- Form1->Edit1->Text=IntToStr(StrToInt(Form1->Edit1->Text)-1);
- //年数减一
- /*或者用下面的方法:
- Form1->CCalendar1->PrevYear;*/
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton1UpClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit1->Text)<9999)
- Form1->Edit1->Text=IntToStr(StrToInt(Form1->Edit1->Text)+1);
- //年数加一
- /*或者用下面的方法:
- Form1->CCalendar1->NextYear;*/
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton2DownClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit2->Text)>1)
- Form1->Edit2->Text=IntToStr(StrToInt(Form1->Edit2->Text)-1);
- //月份减一
- /*或者用下面的方法
- Form1->CCalendar1->PrevMonth;*/
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton2UpClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit2->Text)<12)
- Form1->Edit2->Text=IntToStr(StrToInt(Form1->Edit2->Text)+1);
- //月份加一
- /*或者用下面的方法
- Form1->CCalendar1->NextMonth;*/
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton3DownClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit3->Text)>1)
- Form1->Edit3->Text=IntToStr(StrToInt(Form1->Edit3->Text)-1);
- //日期减一
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CSpinButton3UpClick(TObject *Sender)
- {
- if (StrToInt(Form1->Edit3->Text)<31)
- Form1->Edit3->Text=IntToStr(StrToInt(Form1->Edit3->Text)+1);
- //日期加一
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- Form1->Edit4->Text=TimeToStr(Time());
- //动态显示系统时间
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit1Change(TObject *Sender)
- {
- Form1->CCalendar1->Year=StrToInt(Form1->Edit1->Text);
- //年数改变
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit2Change(TObject *Sender)
- {
- Form1->CCalendar1->Month=StrToInt(Form1->Edit2->Text);
- //月份改变
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit3Change(TObject *Sender)
- {
- Form1->CCalendar1->Day=StrToInt(Form1->Edit3->Text);
- //日期改变
- }
- //---------------------------------------------------------------------------