Пример создания формы Автосерфинга. Он конечно немного грубоват и неможет открывать некоторые защиты ActiveX.
В поле ComboBox в String заносятся http://URL страниц.
Timer выполняет невидимый или видимый отсчет времени.
Unit.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "SHDocVw_OCX.h"
#include <OleCtrls.hpp>
#include <ComCtrls.hpp>
#include <TabNotBk.hpp>
#include <ExtCtrls.hpp>
#include <VCSpell3.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TButton *Button2;
TButton *Button3;
TButton *Button4;
TButton *Button5;
TButton *Button6;
TComboBox *ComboBox1;
TTimer *Timer1;
TCppWebBrowser *CppWebBrowser1;
TButton *Button7;
TVSSpell *VSSpell1;
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button5Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall Button4Click(TObject *Sender);
void __fastcall Button6Click(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
void __fastcall ComboBox1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift);
void __fastcall Button7Click(TObject *Sender);
void __fastcall Timer1Timer(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
// int i=0;
int c;
int i;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
CppWebBrowser1->GoBack(); //êíîïêà Íàçàä
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
CppWebBrowser1->GoForward(); //êíîïêà Âïåðåä
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
CppWebBrowser1->Stop(); //êíîïêà Ñòîï
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
CppWebBrowser1->Refresh(); //êíîïêà Îáíîâèòü
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
CppWebBrowser1->GoHome(); //êíîïêà Äîìàøíÿÿ ñòðàíèöà
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
CppWebBrowser1->Navigate(StringToOleStr(ComboBox1->Text));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1KeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==VK_RETURN)
{
CppWebBrowser1->Navigate(StringToOleStr(ComboBox1->Text)); //Çàãðóæàåì ñòðàíèöû
ComboBox1->Items->Add(ComboBox1->Text); //Äîáàâëÿåì èñïîëüçîâàííûå àäðåñà
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
Timer1->Enabled=true;
for (c=0;c<1000;c++)
{
// CppWebBrowser1->Refresh(); //êíîïêà Îáíîâèòü
//i++;
for (ComboBox1->ItemIndex=0;ComboBox1->ItemIndex<44; )
{
//CppWebBrowser1->Navigate(StringToOleStr(ComboBox1->Text));
for(DWORD tt=GetTickCount();
GetTickCount()-tt<10000;
Sleep(10)) Application->ProcessMessages();
if ( ComboBox1->ItemIndex==44)
{
//CppWebBrowser1->Navigate(StringToOleStr(ComboBox1->Items->Text="http://vol-alchevsk.ucoz.net"));
ComboBox1->ItemIndex==0;
// ;
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
CppWebBrowser1->Navigate(StringToOleStr(ComboBox1->Text));
ComboBox1->ItemIndex++;
}
//---------------------------------------------------------------------------
|