www.pudn.com > CP_IVR.zip > HDevices.cpp


// HDevices.cpp: implementation of the CHDevices class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "HDevices.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CHDevices::CHDevices() 
{ 
	 
} 
 
CHDevices::~CHDevices() 
{ 
	tagDevice* pTag; 
	for (int i=0;iID = id; 
	dev->sName = snm; 
	dev->bDefault = FALSE; 
 
	m_arr.Add(dev); 
} 
 
int CHDevices::Find(UINT id) 
{ 
	for (int i=0;iID == id ) return i; 
	}; 
 
	return -1; 
} 
 
int CHDevices::GetCount() 
{ 
	return m_arr.GetSize(); 
} 
 
CString CHDevices::GetItemName(UINT nIndex, BOOL bById) 
{ 
	int index = 0; 
 
	if (bById) { 
		if ( (index = Find(nIndex))==-1 ) return _T(""); 
		else return ((tagDevice*)m_arr.GetAt(index))->sName; 
	} else { 
		if (nIndex>(UINT)m_arr.GetSize()) return _T(""); 
		 
		return ( ((tagDevice*)m_arr.GetAt(nIndex))->sName); 
	} 
} 
 
void CHDevices::Reset() 
{ 
	m_arr.RemoveAll(); 
} 
 
int CHDevices::GetDefault() 
{ 
	for (int i=0;ibDefault == TRUE ) return i; 
	}; 
 
	return -1; 
} 
 
void CHDevices::SetDefaultItem(UINT id) 
{ 
	int index; 
	if ( (index = Find(id)) == -1 ) return; 
	 
	((tagDevice*)m_arr.GetAt(index))->bDefault = TRUE; 
} 
 
 
UINT CHDevices::GetItemId(UINT nIndex) 
{ 
	if (nIndex>(UINT)m_arr.GetSize()) return 0; 
	return ((tagDevice*)m_arr.GetAt(nIndex))->ID; 
} 
 
void CHDevices::Restart() 
{ 
	tagDevice* pTag; 
	for (int i=0;i