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

#ifndef FrameSamsungXnsActiveXFH
#define FrameSamsungXnsActiveXFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "cxButtons.hpp"
#include "cxGraphics.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "dxSkinBlack.hpp"
#include "dxSkinMcSkin.hpp"
#include "dxSkinsCore.hpp"
#include "ImageBtn.h"
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <Menus.hpp>
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxEdit.hpp"
#include "cxLabel.hpp"
#include <OleCtrls.hpp>
#include "cxTextEdit.hpp"
#include "XNSSDKDEVICELib_OCX.h"
#include "XNSSDKWINDOWLib_OCX.h"
#include "cxDropDownEdit.hpp"
#include "cxMaskEdit.hpp"   /* idhttp 권한 설정을 위해 필요함 */

//---------------------------------------------------------------------------
class TFrameSamsungXnsActiveX : public TFrame
{
__published:	// IDE-managed Components
    TPanel *PnlCamConrtol;
    TcxButton *BtnImageSave;
    TPanel *PnlPTZ;
    TImageBtn *BtnUpLeft;
    TImageBtn *BtnUp;
    TImageBtn *BtnUpRight;
    TImageBtn *BtnLeft;
    TImageBtn *BtnHome;
    TImageBtn *BtnRight;
    TImageBtn *BtnDownLeft;
    TImageBtn *BtnDown;
    TImageBtn *BtnDownRight;
    TImageBtn *BtnZoomIn;
    TImageBtn *BtnZoomOut;
    TImageBtn *BtnFocusIn;
    TImageBtn *BtnFocusOut;
    TLabel *Label20;
    TTrackBar *PTZSpeed;
    TMemo *reMsg;
    TPanel *PnlBack;
    TPanel *PnlStreamInfo;
    TPanel *PnlCameraBack;
    TcxLabel *cxLabel1;
    TcxButton *BtnConnect;
    TPanel *PnlCamera;
    TcxLabel *LblErrMsg;
    TcxTextEdit *EdStreamUrl;
    TcxLabel *cxLabel2;
    TcxLabel *cxLabel3;
    TcxTextEdit *EdStreamId;
    TcxTextEdit *EdStreamPswd;
    TcxLabel *cxLabel4;
    TXnsSdkWindow *XnsSdkWindow1;
    TXnsSdkDevice *XnsSdkDevice1;
    TcxComboBox *CboModel;
    TcxTextEdit *EdIpAddress;
    TcxTextEdit *EdPort;
    TcxLabel *cxLabel5;
    TcxButton *BtnDisconnect;
    void __fastcall BtnWebCamControlMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
    void __fastcall BtnWebCamControlMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
    void __fastcall BtnConnectClick(TObject *Sender);
    void __fastcall XnsSdkDevice1ConnectFailed(TObject *Sender, long nDeviceID, long nControlID);
    void __fastcall XnsSdkDevice1DeviceStatusChanged(TObject *Sender, long nDeviceID, long nErrorCode, long nDeviceStatus,
          long nHddCondition);
    void __fastcall BtnDisconnectClick(TObject *Sender);
    void __fastcall reMsgDblClick(TObject *Sender);
private:	// User declarations

    bool   FStrmPlay;
    String FStrmUser;
    String FStrmPswd;
    String FStrmUrl;
    String FStrmHttp;
    String FStrmAddr;
    long   FStrmHandle;

	long   m_hDevice;			// Device handle
	long   m_hMediaSource;		// Media stream ID
	long   m_nControlId;		// Control ID
	bool   m_bIsMediaPlay;

public:
    bool __fastcall SetupWebCamera();
    void __fastcall ReleaseWebCamera();
    bool __fastcall OpenWebCamera();

    bool __fastcall ConnectWebCamera();
    void __fastcall DisconnectWebCamera();
    void __fastcall CloseWebCamera();
    void __fastcall OpenStream();
    void __fastcall CloseStream();
    void __fastcall ControlCamera(int nCommand);

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