#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include "NetSDKDLL.h"



class CLogInfo
{
public:
	CLogInfo(long user, long nCode, char *pRes)
	{	
		lUser = user;
		nStateCode = nCode;
		pResponse = strdup(pRes);
	};
	
	~CLogInfo()
	{
		lUser = 0;
		nStateCode = 0;
		SAFE_FREE(pResponse);
	};
	LONG lUser; 
	LONG nStateCode;
	char *pResponse;
};
// CDevSearch 对话框

struct AlarmInfo{
	ALARM_ITEM Alarm;
	int iUserID;
};
struct IPC
{
	IPC_ENTRY m_IPCEntry;
	int m_iIndex; //搜索索引
};

class CDevSearch : public CDialog
{
	DECLARE_DYNAMIC(CDevSearch)

public:
	CDevSearch(CRect rcWnd, CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDevSearch();
	
// 对话框数据
	enum { IDD = IDD_DLG_DEVSEARCH };
	LONG __stdcall	StatusCallBack(LONG lUser,LONG mlStateCode,char *mpResponse,void *pUser);
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()

private:
	CRect m_rcClient;

	CButton m_ctlBTNSearch;
	CListCtrl m_ctlDeviceList;

	virtual BOOL OnInitDialog();
	virtual BOOL PreTranslateMessage(MSG* pMsg);

	afx_msg void OnBnClickedBtnSearch();
	afx_msg void OnBnClickedBtnAdd();


	BOOL FlushDevList();

	
private:
	BOOL m_bSearch;
	int m_lLastIPCCount;
	int IPCSearch(BOOL bSearch);
	CMap<int, int&, IPC, IPC&> m_IPCList; // <列表位置，IPC>
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnNMDblclkListDevice(NMHDR *pNMHDR, LRESULT *pResult);
	CListCtrl m_ctlAlarmList;
	afx_msg void OnBnClickedCkDevsearch();
	afx_msg void OnBnClickedCkAlarmevent();
	CButton m_ctlCKAlarm;
	CButton m_ctlCKSearch;
	CButton m_ctlDEVAdd;
	CRITICAL_SECTION m_csAlarmEvent;
	CList<AlarmInfo> m_listAlarmEvent; 
};
