📄 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;i<m_arr.GetSize();i++ ){
if ( (pTag=(tagDevice*)m_arr.GetAt(i))!=NULL ) {
delete pTag;
}
}
m_arr.RemoveAll();
}
void CHDevices::Save()
{
}
void CHDevices::Add(tagDevice &newDev)
{
}
void CHDevices::Add(UINT id, TCHAR* name)
{
CString snm = name;
if (snm.GetLength()==0) return;
tagDevice* dev = new tagDevice;
dev->ID = id;
dev->sName = snm;
dev->bDefault = FALSE;
m_arr.Add(dev);
}
int CHDevices::Find(UINT id)
{
for (int i=0;i<m_arr.GetSize();i++ ){
if ( ((tagDevice*)m_arr.GetAt(i))->ID == 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;i<m_arr.GetSize();i++ ){
if ( ((tagDevice*)m_arr.GetAt(i))->bDefault == 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<m_arr.GetSize();i++ ){
if ( (pTag=(tagDevice*)m_arr.GetAt(i))!=NULL ) {
delete pTag;
}
}
m_arr.RemoveAll();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -