// 8k_diDlg.cpp : implementation file // #include "stdafx.h" #include "8k_di.h" #include "8k_diDlg.h" #include "PACSDK.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMy8k_diDlg dialog CMy8k_diDlg::CMy8k_diDlg(CWnd* pParent /*=NULL*/) : CDialog(CMy8k_diDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMy8k_diDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CMy8k_diDlg, CDialog) #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP) ON_WM_SIZE() #endif //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON1, &CMy8k_diDlg::OnBnClickedButton1) END_MESSAGE_MAP() // CMy8k_diDlg message handlers BOOL CMy8k_diDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here //set default value SetDlgItemText(IDC_COMBO1,L"1"); SetDlgItemText(IDC_EDIT1,L"16"); return TRUE; // return TRUE unless you set the focus to a control } #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP) void CMy8k_diDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/) { if (AfxIsDRAEnabled()) { DRA::RelayoutDialog( AfxGetResourceHandle(), this->m_hWnd, DRA::GetDisplayMode() != DRA::Portrait ? MAKEINTRESOURCE(IDD_MY8K_DI_DIALOG_WIDE) : MAKEINTRESOURCE(IDD_MY8K_DI_DIALOG)); } } #endif void CMy8k_diDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here TCHAR temp[20]; DWORD DIValue; //get user set slot GetDlgItemText(IDC_COMBO1,temp,20); int slot = _wtoi(temp); //get user set total channel GetDlgItemText(IDC_EDIT1,temp,20); int channel = _wtoi(temp); //use pac_ReadAI functio to read DI data BOOL iret = pac_ReadDI(0,slot,channel,&DIValue); if(!iret){ ::MessageBox(NULL,L"Read DI error",L"8k_di",MB_OK); }else{ wsprintf(temp,L"%d",DIValue); SetDlgItemText(IDC_EDIT2,temp); wsprintf(temp,L"0x%lx",DIValue); SetDlgItemText(IDC_EDIT3,temp); } }