
// TestWrapperAPIDlg.h : header file
//

#pragma once
#include "QuoteAPI.h"
#include "TradeAPI.h"
#include "afxwin.h"

// CTestWrapperAPIDlg dialog
class CTestWrapperAPIDlg : public CDialogEx, CQuoteEventReceiver, CTradeEventReceiver
{
// Construction
public:
	CTestWrapperAPIDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TESTWRAPPERAPI_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();

	DECLARE_MESSAGE_MAP()
public:
	void WriteLog(CString strLog);
	CString GetSymbolClassifications(CString strParam1=_T(""), CString strParam2=_T(""), CString strParam3=_T(""), CString strParam4=_T(""), CString strParam5=_T(""));
	virtual void OnQuoteCommandMsg(long lMsgType, long lMsgCode, LPCTSTR strMsg);	//连线状态
	virtual void OnQuoteData(long lSymbolType, long lDataType, LPDISPATCH lpDispData);	//报价资料
	virtual void OnQuoteDataSyn(long lSymbolType, long lDataType, LPDISPATCH lpDispData, LPCTSTR lpModifiedFields);	//报价资料(不并tick)
	virtual void OnQuoteSymbolClassificationsUpdate();	//商品分类表更新

	virtual void OnTradeCommandMsg(long lMsgType, long lMsgCode, LPCTSTR strMsg);	//连线状态
	virtual void OnTradeAccountUpdate(long Type, LPCTSTR AcctMask, long Count); //帐号与帐务资料
	virtual void OnTradeReportReset();	//回报清空回补
	virtual void OnTradeExecutionReport(LPCTSTR ReportID);	//即时委托
	
protected:
	CQuoteAPI m_QuoteAPI;
	TradeAPI m_TradeAPI;
	CString m_strLog;
	int m_nLogstatus;
	bool m_blClassificationsUpdate;

	void ProcessRealtimeQuoteData(LONG lSecurityType, LPDISPATCH lpDispQuoteData);	//即时报价
	void ProcessMatchListQuoteData(LONG lSecurityType, LPDISPATCH lpDispQuoteData);	//分时
	void ProcessPriceListQuoteData(LONG lSecurityType, LPDISPATCH lpDispQuoteData);	//分价
	void ProcessTechanicalQuoteData(LONG lSecurityType, LPDISPATCH lpDispQuoteData);	//K线
	void ProcessOrderReport(CString strReportID, bool bRealtime);	//回报处理
	void ProcessFillOrderReport(CString strReportID);	//成交回报处理
	void ProcessAccount(LONG lType, LONG lCount);	//帐号处理
	void ProcessMargin(CString strAcctMask, LONG lCount);		//资金处理
	void ProcessPositionRT(CString strAcctMask, LONG lCount);	//部位处理
	void SymbolSelect(int nSelect);	//呼叫商品选择
public:
	afx_msg void OnBnClickedBtnConnect();
	afx_msg void OnBnClickedBtnDisconnect();
	CComboBox m_ComboDataType;
	afx_msg void OnBnClickedBtnSub();
	afx_msg void OnBnClickedBtnUnsub();
	afx_msg void OnBnClickedBtnClear();
	CComboBox m_ComboTradeQueryType;
	afx_msg void OnBnClickedBtnConnect2();
	afx_msg void OnBnClickedBtnDisconnect2();
	CComboBox m_cmbAccount;
	CEdit m_edtOrderType;
	CEdit m_edtBS;
	CEdit m_edtTimeInForce;
	CEdit m_edtPositionEffect;
	CEdit m_edtPrice;
	CEdit m_edtQty;
	afx_msg void OnBnClickedBtnDoorder();
	CEdit m_edtTradeSymbol;
	afx_msg void OnBnClickedBtnQuery();
	afx_msg void OnBnClickedBtnSymbolselect();
	afx_msg void OnBnClickedBtnSymbolselect2();
};
