// DetectDialog.cpp : implementation file // #include "stdafx.h" #include "sample1.h" #include "DetectDialog.h" #include "AIOUSB.H" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DetectDialog dialog DetectDialog::DetectDialog(CWnd* pParent /*=NULL*/) : CDialog(DetectDialog::IDD, pParent) { //{{AFX_DATA_INIT(DetectDialog) m_message = _T(""); //}}AFX_DATA_INIT } void DetectDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DetectDialog) DDX_Control(pDX, IDC_LIST1, m_deviceList); DDX_Text(pDX, IDC_EDIT_MESSAGE, m_message); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(DetectDialog, CDialog) //{{AFX_MSG_MAP(DetectDialog) ON_BN_CLICKED(IDC_DETECT_BTN, OnDetectBtn) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DetectDialog message handlers void DetectDialog::OnDetectBtn() { // TODO: Add your control notification handler code here unsigned long DeviceMask; unsigned long PID; CString nom; bool Found; char *buf; m_deviceList.ResetContent(); DeviceMask = GetDevices(); for (int i = 0; i <= 7; i++) { DeviceOK[i] = false; if (DeviceMask & (1 << i)) { QueryDeviceInfo(i, &PID, NULL, NULL, NULL, NULL); switch(PID) { case 0x8010: nom = " USB-IIRO-16"; DeviceOK[i] = true; Found = true; break; default: buf = nom.GetBuffer(5); itoa(PID, buf, 16); nom.ReleaseBuffer(); nom += " "; break; } } else { nom = ""; } m_deviceList.InsertString(i, nom); } if (Found) { m_message = "Select the device you want to work with and click Go."; } else { m_message = "No compatible devices found; your device may not be installed, or may not be installed properly. Click Redetect to check again."; } UpdateData(true); } BOOL DetectDialog::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here OnDetectBtn(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void DetectDialog::OnOK() { // TODO: Add extra validation here index = m_deviceList.GetCurSel(); if (index != LB_ERR) { if (DeviceOK[index]) { } else { MessageBox("Invalid selection", "Exiting"); } } CDialog::OnOK(); }