#ifndef OverbyteIcsHttpThr1H
#define OverbyteIcsHttpThr1H

#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>

#include "OverbyteIcsHttpThr2.h"

const unsigned WM_THREAD_RESULT = WM_USER + 1;
const unsigned WM_LOG = WM_USER + 2;
const int MaxThreads = 6;

class THttpThreadForm : public TForm
{
__published:
    TEdit *URLEdit;
    TMemo *ResultsMemo;
    TButton *DoItButton;
    TLabel *Label14;
    TEdit *ProxyEdit;
    TLabel *Label15;
    TGroupBox *GroupBox1;
    TLabel *Label1;
    TLabel *Label2;
    TLabel *Label3;
    TLabel *Label4;
    TLabel *Label5;
    TLabel *Label6;
    TLabel *Thread0Label;
    TLabel *Thread1Label;
    TLabel *Thread2Label;
    TLabel *Thread3Label;
    TLabel *Thread5Label;
    TLabel *Thread4Label;
    TEdit *EditTotal;
    void __fastcall DoItButtonClick(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall FormShow(TObject *Sender);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);

private:
    bool FInitialized;
    String FIniFileName;
    bool FTerminating;
    THTTPThread *FThreads[MaxThreads];
    void DisplayThreadState(int Which, TThreadState State);

protected:
    void __fastcall WmLog(TMessage &Msg);
    void __fastcall WmThreadResult(TMessage &Msg);

    BEGIN_MESSAGE_MAP
        VCL_MESSAGE_HANDLER(WM_LOG, TMessage, WmLog)
        VCL_MESSAGE_HANDLER(WM_THREAD_RESULT, TMessage, WmThreadResult)
    END_MESSAGE_MAP(TForm)

public:
    __fastcall THttpThreadForm(TComponent *Owner);
    __fastcall ~THttpThreadForm();
    void ProcessResults(THTTPThread *AThread, bool Success);
};

extern PACKAGE THttpThreadForm *HttpThreadForm;

#endif
