//---------------------------------------------------------------------------
#ifndef CppTestFormH
#define CppTestFormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>

#include <memory>
#include "SynchedThreads.h"
#include <syncobjs.hpp>

//---------------------------------------------------------------------------
class TCppTest : public TForm
{
__published:	// IDE-managed Components
        TButton *BeepBtn;
        TButton *WaitBtn;
        TButton *StopStartMsgWaitBtn;
        TButton *InfiniteWaitBtn;
        TButton *MsgWaitBtn;
        TButton *StopStartWaitBtn;
        TButton *EventWaitBtn;
        TButton *UntilBtn;
        TButton *SpawnBtn;

        void __fastcall FormCreate(TObject *Sender);
        void __fastcall BeepBtnClick(TObject *Sender);
        void __fastcall WaitBtnClick(TObject *Sender);
        void __fastcall MsgWaitBtnClick(TObject *Sender);
        void __fastcall StopStartWaitBtnClick(TObject *Sender);
        void __fastcall StopStartMsgWaitBtnClick(TObject *Sender);
        void __fastcall InfiniteWaitBtnClick(TObject *Sender);
        void __fastcall EventWaitBtnClick(TObject *Sender);
        void __fastcall UntilBtnClick(TObject *Sender);
        void __fastcall SpawnBtnClick(TObject *Sender);
private:	// User declarations
  std::auto_ptr<TStopStartThread> Thread;
  TWaitThread*                    WaitThread;
  std::auto_ptr<TEvent>           UntilFlag;

  void Beep(void* Data)          { MessageBeep(0);  };
  void Pause(void* Data)         { Sleep(7500);     };
  void InfinitePause(void* Data) { Sleep(INFINITE); };

protected:
    void __fastcall wmClose(TMessage Message);

    BEGIN_MESSAGE_MAP
      MESSAGE_HANDLER(WM_CLOSE, TMessage, wmClose);
    END_MESSAGE_MAP(TForm)

public:		// User declarations
        __fastcall TCppTest(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TCppTest *CppTest;
//---------------------------------------------------------------------------
#endif