- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "Unitmain.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- #pragma resource "bitmap.res"
- TFormControl *FormControl;
- //---------------------------------------------------------------------------
- __fastcall TFormControl::TFormControl(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::Timer1Timer(TObject *Sender)
- {static int i=0;
- if(i>2)i=0;
- if(i==1)
- Image1->Picture=Image2->Picture;
- else
- Image1->Picture=Image3->Picture;
- i++;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::FormShow(TObject *Sender)
- {
- Timer1->Enabled=true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::FormCreate(TObject *Sender)
- {
- Image1->Picture=Image3->Picture;
- TRegistry *Registry = new TRegistry;
- try
- {
- Registry->RootKey =HKEY_CURRENT_USER;
- if(Registry->KeyExists("\Software\CODEHUNTER")==true){
- Registry->OpenKey("\Software\CODEHUNTER", true);
- picdir=Registry->ReadString("PicDir");
- frequence=Registry->ReadInteger("frequence");
- Registry->CloseKey();
- }
- else
- {
- if(picdir=="")picdir="no";
- if(frequence<0||frequence>6)
- frequence=1;
- Registry->OpenKey("\Software\CODEHUNTER",true);
- Registry->WriteString("PicDir",picdir);
- Registry->WriteInteger("frequence",frequence);
- }
- if(picdir=="")picdir="no";
- if(frequence<0||frequence>6)
- frequence=1;
- TrackBar1->Position=frequence;
- StaticText1->Caption=picdir;
- }
- __finally
- {
- delete Registry;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::Button2Click(TObject *Sender)
- {
- picdir="";
- if(SelectDirectory("Select Picture Dir","",picdir))
- StaticText1->Caption=picdir;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::Button1Click(TObject *Sender)
- {
- if(picdir=="") picdir="no";
- this->frequence=TrackBar1->Position;
- TRegistry *Reg = new TRegistry;
- try
- {
- Reg->RootKey = HKEY_CURRENT_USER;
- if (Reg->OpenKey("\Software\CODEHUNTER", false))
- {
- Reg->WriteString("PicDir",picdir);
- Reg->WriteInteger("frequence",frequence);
- Reg->CloseKey();
- }
- }
- __finally
- {
- delete Reg;
- }
- this->Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormControl::Button3Click(TObject *Sender)
- {
- Form1->Show();
- }
- //---------------------------------------------------------------------------