Unitmain.cpp
上传用户:cqslgg
上传日期:2009-12-10
资源大小:128k
文件大小:3k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. #include "Unitmain.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. #pragma resource "bitmap.res"
  10. TFormControl *FormControl;
  11. //---------------------------------------------------------------------------
  12. __fastcall TFormControl::TFormControl(TComponent* Owner)
  13.         : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TFormControl::Timer1Timer(TObject *Sender)
  18. {static int i=0;
  19. if(i>2)i=0;
  20. if(i==1)
  21. Image1->Picture=Image2->Picture;
  22. else
  23. Image1->Picture=Image3->Picture;
  24. i++;
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TFormControl::FormShow(TObject *Sender)
  28. {
  29. Timer1->Enabled=true;
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TFormControl::FormCreate(TObject *Sender)
  33. {
  34.  Image1->Picture=Image3->Picture;
  35.     TRegistry *Registry = new TRegistry;
  36.   try
  37.   {
  38.     Registry->RootKey =HKEY_CURRENT_USER;
  39.     if(Registry->KeyExists("\Software\CODEHUNTER")==true){
  40.     Registry->OpenKey("\Software\CODEHUNTER", true);
  41.     picdir=Registry->ReadString("PicDir");
  42.     frequence=Registry->ReadInteger("frequence");
  43.     Registry->CloseKey();
  44.     }
  45.     else
  46.     {
  47.     if(picdir=="")picdir="no";
  48.     if(frequence<0||frequence>6)
  49.      frequence=1;
  50.     Registry->OpenKey("\Software\CODEHUNTER",true);
  51.     Registry->WriteString("PicDir",picdir);
  52.     Registry->WriteInteger("frequence",frequence);
  53.     }
  54.     if(picdir=="")picdir="no";
  55.     if(frequence<0||frequence>6)
  56.      frequence=1;
  57.     TrackBar1->Position=frequence;
  58.     StaticText1->Caption=picdir;
  59.   }
  60.   __finally
  61.   {
  62.     delete Registry;
  63.   }
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TFormControl::Button2Click(TObject *Sender)
  67. {
  68. picdir="";
  69.  if(SelectDirectory("Select Picture Dir","",picdir))
  70.    StaticText1->Caption=picdir;
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TFormControl::Button1Click(TObject *Sender)
  74. {
  75. if(picdir=="") picdir="no";
  76. this->frequence=TrackBar1->Position;
  77. TRegistry *Reg = new TRegistry;
  78.   try
  79.   {
  80.     Reg->RootKey = HKEY_CURRENT_USER;
  81.     if (Reg->OpenKey("\Software\CODEHUNTER", false))
  82.     {
  83.       Reg->WriteString("PicDir",picdir);
  84.       Reg->WriteInteger("frequence",frequence);
  85.       Reg->CloseKey();
  86.     }
  87.   }
  88.   __finally
  89.   {
  90.     delete Reg;
  91.   }
  92. this->Close();
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TFormControl::Button3Click(TObject *Sender)
  96. {
  97. Form1->Show();
  98. }
  99. //---------------------------------------------------------------------------