📄 apipage.cpp
字号:
// APIPage.cpp : implementation file
//
#include "stdafx.h"
#include "SynView.h"
#include "APIPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAPIPage property page
IMPLEMENT_DYNCREATE(CAPIPage, CPropertyPage)
CAPIPage::CAPIPage() : CPropertyPage(CAPIPage::IDD)
{
//{{AFX_DATA_INIT(CAPIPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pView = 0;
}
CAPIPage::~CAPIPage()
{
}
void CAPIPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAPIPage)
DDX_Control(pDX, IDRESET, m_ResetButton);
DDX_Control(pDX, IDC_PROPERTY, m_PropertyList);
DDX_Control(pDX, IDC_DEVICE, m_DeviceCombo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAPIPage, CPropertyPage)
//{{AFX_MSG_MAP(CAPIPage)
ON_BN_CLICKED(IDRESET, OnReset)
ON_CBN_SELCHANGE(IDC_DEVICE, OnSelchangeDevice)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAPIPage message handlers
struct PropertyDescriptor
{
long lSpecifier;
char *szName;
long lType;
};
#define SPPARAM(name, type) SP_##name, #name, type
static PropertyDescriptor Properties[] =
{
SPPARAM(Version, 0),
SPPARAM(MaxDevices, 0),
SPPARAM(DevicesPresent, 0),
SPPARAM(DriverVersion, 0),
SPPARAM(VersionString, 1),
0, 0, 0 // End of list
};
CString CAPIPage::GetPropertyString(PropertyDescriptor *Descriptor)
{
CString Buffer;
if (!Descriptor->lType)
{
long Prop = m_API.GetLongProperty(Descriptor->lSpecifier);
Buffer.Format("0x%.8x", Prop);
}
else
{
Buffer = (char *) m_API.GetStringProperty(Descriptor->lSpecifier);
}
return Buffer;
}
void CAPIPage::AddProperty(PropertyDescriptor *Descriptor)
{
CString Buffer = GetPropertyString(Descriptor);
if (!Buffer.IsEmpty())
{
CString Entry = Descriptor->szName;
Entry += ":\t";
Entry += Buffer;
m_PropertyList.SetItemDataPtr(m_PropertyList.AddString(Entry), Descriptor);
}
}
void CAPIPage::InitProperties()
{
m_PropertyList.ResetContent();
int iTabs[] = { 84, 256 };
m_PropertyList.SetTabStops(2, iTabs);
for (int index = 0; ; index++)
{
if (Properties[index].lSpecifier)
AddProperty(Properties + index);
else
break;
}
m_PropertyList.SetHorizontalExtent(400);
}
BOOL CAPIPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_DeviceCombo.ResetContent();
m_API->Initialize();
for (long lHandle = -1; ; )
{
m_API->FindDevice(SE_ConnectionAny, SE_DeviceAny, &lHandle);
if (lHandle != -1)
{
m_Device->Select(lHandle);
_bstr_t ShortName = m_Device.GetStringProperty(SP_ShortName);
m_DeviceCombo.SetItemData(m_DeviceCombo.InsertString(-1, ShortName),
lHandle);
}
else
break;
}
m_DeviceCombo.SetCurSel(m_pView->m_Device.GetLongProperty(SP_Handle));
InitProperties();
CancelToClose();
return TRUE;
}
void CAPIPage::OnReset()
{
m_API->HardwareBroadcast(SF_Configure);
}
void CAPIPage::OnSelchangeDevice()
{
m_pView->NewDevice(
m_DeviceCombo.GetItemData(m_DeviceCombo.GetCurSel()));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -