// DetectDialog.cpp : implementation file // #include "stdafx.h" #include "Samp.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)) { unsigned long NomLen = 256; QueryDeviceInfo(i, &PID, &NomLen, nom.GetBuffer(NomLen), NULL, NULL); nom.ReleaseBuffer(NomLen); switch(PID) { case 0x8040: case 0x8041: case 0x8042: case 0x8043: case 0x8044: case 0x8045: case 0x8046: case 0x8047: case 0x8048: case 0x8049: case 0x804A: case 0x804B: case 0x804C: case 0x804D: case 0x804E: case 0x804F: case 0x8050: case 0x8051: case 0x8052: case 0x8053: case 0x8054: case 0x8055: case 0x8056: case 0x8057: case 0x8058: case 0x8059: case 0x805A: case 0x805B: case 0x805C: case 0x805D: case 0x805E: case 0x805F: case 0x8140: case 0x8141: case 0x8142: case 0x8143: case 0x8144: case 0x8145: case 0x8146: case 0x8147: case 0x8148: case 0x8149: case 0x814A: case 0x814B: case 0x814C: case 0x814D: case 0x814E: case 0x814F: case 0x8150: case 0x8151: case 0x8152: case 0x8153: case 0x8154: case 0x8155: case 0x8156: case 0x8157: case 0x8158: case 0x8159: case 0x815A: case 0x815B: case 0x815C: case 0x815D: case 0x815E: case 0x815F: 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]) { CDialog::OnOK(); } else { MessageBox("Invalid selection", "Exiting"); EndDialog(IDABORT); } } }