www.pudn.com > warsrc.rar > IPShitlistUserTab.cpp


// IPShitlistUserTab.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "WarClient.h" 
#include "edituseroption.h" 
#include "resource.h" 
#include "UserDialog.h" 
#include "IPShitlistUserTab.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CIPShitlistUserTab dialog 
 
 
CIPShitlistUserTab::CIPShitlistUserTab(CWnd* pParent /*=NULL*/) 
	: CWarUserDlgTemplate(CIPShitlistUserTab::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CIPShitlistUserTab) 
	//}}AFX_DATA_INIT 
} 
 
CIPShitlistUserTab::~CIPShitlistUserTab() 
{ 
} 
 
 
void CIPShitlistUserTab::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	CString cBuf; 
	//{{AFX_DATA_MAP(CIPShitlistUserTab) 
	DDX_Control(pDX, IDC_IPDISABLESHITLIST, m_ctlEnableShitlist); 
	//}}AFX_DATA_MAP 
	 
	if (pDX->m_bSaveAndValidate) 
	{ 
		// Shuffle data _from_ dialog 
		// We don't do that. All controls are updated (written) realtime. 
	} 
	else 
	{	 
		// Shuffle data _to_ dialog 
		USER Origin; 
 
		CUserInfo *pUser = m_pUserDlg->GetCurrentUser(); 
 
		if (!pUser || (pUser->m_AliasFor != INVALID_USER_VALUE)) 
		{ 
			// We don't want to handle aliases 
			m_pShitlist->DeleteAllItems(); 
			m_pViplist->DeleteAllItems(); 
			m_pMaxConn->DeleteAllItems(); 
 
			GetDlgItem(IDC_IPTOTALSHITLIST)->EnableWindow(FALSE); 
			GetDlgItem(IDC_IPTOTALVIPLIST)->EnableWindow(FALSE); 
			GetDlgItem(IDC_IPDISABLESHITLIST)->EnableWindow(FALSE); 
			GetDlgItem(IDC_IPMAXCONCURRENTCONN)->EnableWindow(FALSE); 
		} 
		else 
		{ 
			m_pUserDlg->RefreshChkButton(&m_ctlEnableShitlist, "Disable IP Shitlist", Origin); 
 
			m_pShitlist->DeleteAllItems(); 
			m_pViplist->DeleteAllItems(); 
 
			if (m_ctlEnableShitlist.GetCheck() == 0) 
			{ 
				m_pShitlist->UpdateText(); 
				m_pViplist->UpdateText(); 
			} 
		 
			m_pMaxConn->UpdateText(); 
 
			GetDlgItem(IDC_IPTOTALSHITLIST)->EnableWindow(m_ctlEnableShitlist.GetCheck() == 0); 
			GetDlgItem(IDC_IPTOTALVIPLIST)->EnableWindow(m_ctlEnableShitlist.GetCheck() == 0); 
			GetDlgItem(IDC_IPDISABLESHITLIST)->EnableWindow(TRUE); 
			GetDlgItem(IDC_IPMAXCONCURRENTCONN)->EnableWindow(TRUE); 
		} 
	} 
} 
 
 
 
 
BEGIN_MESSAGE_MAP(CIPShitlistUserTab, CWarUserDlgTemplate) 
	//{{AFX_MSG_MAP(CIPShitlistUserTab) 
	ON_BN_CLICKED(IDC_IPDISABLESHITLIST, OnIpdisableshitlist) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CIPShitlistUserTab message handlers 
 
BOOL CIPShitlistUserTab::OnInitDialog()  
{ 
	// These lines will subclass the CListCtrl's in the dialog with 
	// the DLL_WAR_CLIENT CEditUserOption class derived from CListCtrl. 
	// The CEditUserOption class will display the correct value/icon, based 
	// on the users type and at what level the value was found. 
	// The CEditUserOption class handle updating of the user database itself. All 
	// we have to do is to enable/disable the windows and call CEditUserOption::UpdateText() 
	// whenever we want the list controls to reflect the value in the user database. 
	// CEditUserOption handles both a single line (edit control substitute) and normal lists. 
	// Note: CEditUserOption must be constructed prior to calling CDialog::OnInitDialog()! 
 
	m_pShitlist = new CEditUserOption("IP Shitlist", ";", TRUE, IDC_IPTOTALSHITLIST, this); 
	m_pViplist = new CEditUserOption("IP Viplist", ";", TRUE, IDC_IPTOTALVIPLIST, this); 
	m_pMaxConn = new CEditUserOption("IP MaxConn", "", FALSE, IDC_IPMAXCONCURRENTCONN, this); 
 
	CDialog::OnInitDialog(); 
	UpdateData(); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
 
void CIPShitlistUserTab::OnIpdisableshitlist()  
{ 
	USER Origin; 
	// When we use ChkButtonClikked(), the auto state of the dialog button 
	// must be disabled! ChkButtonClikked() will trigger the state. 
	m_pUserDlg->ChkButtonClikked(&m_ctlEnableShitlist, "Enable IP Shitlist"); 
	m_pUserDlg->RefreshChkButton(&m_ctlEnableShitlist, "Enable IP Shitlist", Origin); 
	UpdateData(FALSE); 
}