//---------------------------------------------------------------------------

#ifndef frmMainH
#define frmMainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include "uRs232c.h"
#include <Graphics.hpp>

#define SEND_LEN    256

typedef struct _DataType
{
    BYTE        Code;
    short int   Len;
    BYTE        *Data;
}TDataType;

//---------------------------------------------------------------------------
class TFormMain : public TForm
{
__published:	// IDE-managed Components
    TLabel *Label2;
    TLabel *Label3;
    TButton *btnSend;
    TComboBox *cbCOM;
    TRadioGroup *rdSpeed;
    TRadioGroup *rdParity;
    TRadioGroup *rdStopbit;
    TEdit *EditTimeOut;
    TButton *btnSetup;
    TButton *btnRcv;
    TLabel *Label1;
    TLabel *Label4;
    TLabel *Label5;
    TEdit *EditCode;
    TEdit *EditLength;
    TEdit *EditData;
    TRadioGroup *RadioGroupDtr;
    TRadioGroup *RadioGroupRts;
    TRadioGroup *RadioGroupRecvType;
    TListBox *ListBox1;
    TListBox *ListBox2;
    TListBox *ListBox3;
    TImage *Image1;
    TImage *Image2;
    TImage *Image3;
    TImage *Image4;
    TImage *Image5;
    TImage *Image6;
    TImage *Image7;
    TImage *Image8;
    TImage *Image9;
    TImage *Image10;
    TPanel *MainPanel;
    TImage *CaptureImage;
    TImage *imgClear;
    TImage *imgImageSave;
    TImage *imgExit;
    TPanel *Panel1;
    TPanel *Panel2;
    TPanel *Panel3;
    TPanel *Panel4;
    TPanel *Panel5;
    TPanel *Panel6;
    TPanel *Panel7;
    TPanel *Panel8;
    TPanel *Panel9;
    TPanel *Panel0;
    TImage *imgDelete;
    TImage *imgClearAll;
    TButton *Button1;


    void __fastcall FormDestroy(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall btnSetupClick(TObject *Sender);
    void __fastcall btnSendClick(TObject *Sender);
    void __fastcall EditDataExit(TObject *Sender);
    void __fastcall FormActivate(TObject *Sender);
    void __fastcall btnRcvClick(TObject *Sender);
    void __fastcall RadioGroupRecvTypeClick(TObject *Sender);
    void __fastcall imgClearClick(TObject *Sender);
    void __fastcall imgImageSaveClick(TObject *Sender);
    void __fastcall imgExitClick(TObject *Sender);
    void __fastcall imgDeleteClick(TObject *Sender);
    void __fastcall imgClearAllClick(TObject *Sender);
    void __fastcall Button1Click(TObject *Sender);

//    void __fastcall SaveImg1Click(TObject *Sender);
//    void __fastcall SaveImg2Click(TObject *Sender);
//    void __fastcall SaveImg3Click(TObject *Sender);
//    void __fastcall SaveImg4Click(TObject *Sender);

private:	// User declarations
    TDataType   TxBuff;
    TRS232C     *RS232C;
    TCommParam  CommParam;

    POINT pt[10];

    bool is_est[10];

    int m_numImages;

    void __fastcall SetCommParam(void);
    void __fastcall ClearEdit(void);
    void __fastcall MakeSendData(void);
    void __fastcall ShowRcvData(int iLen, char *bData);
public:		// User declarations
    __fastcall TFormMain(TComponent* Owner);
    void __fastcall UMEvnRxChar(TMessage &Message);
BEGIN_MESSAGE_MAP
    MESSAGE_HANDLER(UM_EVN_RXCHAR, TMessage, UMEvnRxChar)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TFormMain *FormMain;
//---------------------------------------------------------------------------
#endif
