// DlgConnectLimit.cpp : implementation file
//

#include "stdafx.h"
#include "MsSDKTest.h"
#include "MsIpcSDK.h"
#include "MsSDKTestDlg.h"
#include "DlgConnectLimit.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgConnectLimit dialog


CDlgConnectLimit::CDlgConnectLimit(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgConnectLimit::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgConnectLimit)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	LONG m_nUserId = 0;
}


void CDlgConnectLimit::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgConnectLimit)
	DDX_Control(pDX, IDC_COMBO_CONNECTLIMIT, m_cbLimitNum);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgConnectLimit, CDialog)
	//{{AFX_MSG_MAP(CDlgConnectLimit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgConnectLimit message handlers

BOOL CDlgConnectLimit::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	int nLimitNum = 0;
	LONG nResult = Ms_IpcClient_GetMaxConnectionLimit(m_nUserId, &nLimitNum);
	if(nResult)
	{
		CMsSDKTestDlg::OutputTips("Init info failed. Please try again...");
		return FALSE;
	}

	m_cbLimitNum.SetCurSel(nLimitNum);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgConnectLimit::OnOK() 
{
	// TODO: Add extra validation here
	int nLimitNum = 0;
	nLimitNum = m_cbLimitNum.GetCurSel();
	if(!Ms_IpcClient_SetMaxConnectionLimit(m_nUserId, nLimitNum))
	{
		CMsSDKTestDlg::OutputTips("Set Connect Limit Successfully.");
	}else{
		AfxMessageBox("Failed.");
		return;
	}

	CDialog::OnOK();
}
