|
|
// LedScreenTestDlg.cpp : implementation file
|
|
|
//
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "LedScreenTest.h"
|
|
|
#include "LedScreenTestDlg.h"
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
#define new DEBUG_NEW
|
|
|
#undef THIS_FILE
|
|
|
static char THIS_FILE[] = __FILE__;
|
|
|
#endif
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
// CAboutDlg dialog used for App About
|
|
|
|
|
|
class CAboutDlg : public CDialog
|
|
|
{
|
|
|
public:
|
|
|
CAboutDlg();
|
|
|
|
|
|
// Dialog Data
|
|
|
//{{AFX_DATA(CAboutDlg)
|
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
|
//}}AFX_DATA
|
|
|
|
|
|
// ClassWizard generated virtual function overrides
|
|
|
//{{AFX_VIRTUAL(CAboutDlg)
|
|
|
protected:
|
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
|
//}}AFX_VIRTUAL
|
|
|
|
|
|
// Implementation
|
|
|
protected:
|
|
|
//{{AFX_MSG(CAboutDlg)
|
|
|
//}}AFX_MSG
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
};
|
|
|
|
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
|
{
|
|
|
//{{AFX_DATA_INIT(CAboutDlg)
|
|
|
//}}AFX_DATA_INIT
|
|
|
}
|
|
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
{
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
//{{AFX_DATA_MAP(CAboutDlg)
|
|
|
//}}AFX_DATA_MAP
|
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|
|
//{{AFX_MSG_MAP(CAboutDlg)
|
|
|
// No message handlers
|
|
|
//}}AFX_MSG_MAP
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
// CLedScreenTestDlg dialog
|
|
|
|
|
|
CLedScreenTestDlg::CLedScreenTestDlg(CWnd* pParent /*=NULL*/)
|
|
|
: CDialog(CLedScreenTestDlg::IDD, pParent)
|
|
|
{
|
|
|
//{{AFX_DATA_INIT(CLedScreenTestDlg)
|
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
|
//}}AFX_DATA_INIT
|
|
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
{
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
//{{AFX_DATA_MAP(CLedScreenTestDlg)
|
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|
|
//}}AFX_DATA_MAP
|
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CLedScreenTestDlg, CDialog)
|
|
|
//{{AFX_MSG_MAP(CLedScreenTestDlg)
|
|
|
ON_WM_SYSCOMMAND()
|
|
|
ON_WM_PAINT()
|
|
|
ON_WM_QUERYDRAGICON()
|
|
|
ON_BN_CLICKED(IDC_BUTTONINIT, OnButtoninit)
|
|
|
ON_BN_CLICKED(IDC_BUTTONOPEN, OnButtonopen)
|
|
|
ON_BN_CLICKED(IDC_BUTTONSHOEID, OnButtonshoeid)
|
|
|
ON_BN_CLICKED(IDC_BUTTONSHOWLIGHT, OnButtonshowlight)
|
|
|
ON_BN_CLICKED(IDC_BUTTONCLOSE, OnButtonclose)
|
|
|
ON_BN_CLICKED(IDC_BUTTONSTATES, OnButtonstates)
|
|
|
//}}AFX_MSG_MAP
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
// CLedScreenTestDlg message handlers
|
|
|
|
|
|
BOOL CLedScreenTestDlg::OnInitDialog()
|
|
|
{
|
|
|
CDialog::OnInitDialog();
|
|
|
|
|
|
// Add "About..." menu item to system menu.
|
|
|
|
|
|
// IDM_ABOUTBOX must be in the system command range.
|
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
|
|
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
|
if (pSysMenu != NULL)
|
|
|
{
|
|
|
CString strAboutMenu;
|
|
|
strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
|
if (!strAboutMenu.IsEmpty())
|
|
|
{
|
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 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
|
|
|
InitStr();
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
|
{
|
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
|
{
|
|
|
CAboutDlg dlgAbout;
|
|
|
dlgAbout.DoModal();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
|
// this is automatically done for you by the framework.
|
|
|
|
|
|
void CLedScreenTestDlg::OnPaint()
|
|
|
{
|
|
|
if (IsIconic())
|
|
|
{
|
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
|
|
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
|
|
|
|
|
// Center icon in client rectangle
|
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
|
CRect rect;
|
|
|
GetClientRect(&rect);
|
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
|
|
// Draw the icon
|
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CDialog::OnPaint();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::InitStr()
|
|
|
{
|
|
|
CEdit * pEdit;
|
|
|
CListBox * pList;
|
|
|
// char buf[256];
|
|
|
|
|
|
pEdit = (CEdit *)(GetDlgItem(IDC_EDITIPADDR));
|
|
|
pEdit->SetWindowText("127.0.0.1:6600:user:password");
|
|
|
|
|
|
pList = (CListBox *)(GetDlgItem(IDC_LISTSHOWID));
|
|
|
|
|
|
pList->AddString("MTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
pList->AddString("ETC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
pList->AddString("MTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>");
|
|
|
pList->AddString("ETC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>");
|
|
|
|
|
|
pEdit = (CEdit *)(GetDlgItem(IDC_EDITLIGHT));
|
|
|
pEdit->SetWindowText("16");
|
|
|
|
|
|
m_initFlag =0;
|
|
|
m_hDll =NULL;
|
|
|
m_ledhdl =NULL;
|
|
|
// m_ledhdl =NULL:
|
|
|
|
|
|
m_funOpenLedScr =NULL;
|
|
|
m_funCloseLedScr =NULL;
|
|
|
m_funLedScrShow =NULL;
|
|
|
m_funLedScrSetLight =NULL;
|
|
|
m_funLedScrGetStatus =NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
// The system calls this to obtain the cursor to display while the user drags
|
|
|
// the minimized window.
|
|
|
HCURSOR CLedScreenTestDlg::OnQueryDragIcon()
|
|
|
{
|
|
|
return (HCURSOR) m_hIcon;
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtoninit()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
CString path;
|
|
|
path ="DevLEDScreen.dll";
|
|
|
|
|
|
if(1 == m_initFlag)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(! m_hDll)
|
|
|
{
|
|
|
m_hDll = LoadLibrary(path); //<2F><><EFBFBD><EFBFBD>dll<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>hdllʵ<6C><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if(! m_hDll)
|
|
|
{
|
|
|
MessageBox("DevLEDScreen.dllʧ<6C><CAA7>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
m_funOpenLedScr = (fun_OpenLedScr)GetProcAddress(m_hDll,"OpenLedScr");
|
|
|
|
|
|
if(! m_funOpenLedScr)
|
|
|
{
|
|
|
MessageBox("OpenLedScr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_funCloseLedScr= (fun_CloseLedScr)GetProcAddress(m_hDll,"CloseLedScr");
|
|
|
if(! m_funCloseLedScr)
|
|
|
{
|
|
|
MessageBox("CloseLedScr <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_funLedScrShow = (fun_LedScrShow)GetProcAddress(m_hDll,"LedScrShow");
|
|
|
|
|
|
if(! m_funLedScrShow)
|
|
|
{
|
|
|
MessageBox("LedScrShow<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_funLedScrSetLight = (fun_LedScrSetLight)GetProcAddress(m_hDll,"LedScrSetLight");
|
|
|
if(! m_funLedScrSetLight)
|
|
|
{
|
|
|
MessageBox("LedScrSetLight<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_funLedScrGetStatus = (fun_LedScrGetStatus)GetProcAddress(m_hDll,"LedScrGetStatus");
|
|
|
if(! m_funLedScrGetStatus)
|
|
|
{
|
|
|
MessageBox("LedScrGetStatus<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_initFlag =1;
|
|
|
path = "<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>";
|
|
|
|
|
|
ShowStates(path);
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtonopen()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
if(! m_funOpenLedScr)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
CString cstr;
|
|
|
CEdit * pEdit;
|
|
|
int iLen;
|
|
|
char buf[128];
|
|
|
|
|
|
pEdit = (CEdit *)(GetDlgItem(IDC_EDITIPADDR));
|
|
|
pEdit->GetWindowText(cstr);
|
|
|
|
|
|
iLen = cstr.GetLength();
|
|
|
if ((iLen < 1) || (iLen > 120))
|
|
|
{
|
|
|
MessageBox("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ںų<EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
strcpy(buf, cstr.GetBuffer(0));
|
|
|
m_ledhdl = m_funOpenLedScr(1, buf);
|
|
|
|
|
|
if (!m_ledhdl)
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cstr = "<EFBFBD>ɹ<EFBFBD>";
|
|
|
|
|
|
}
|
|
|
|
|
|
ShowStates(cstr);
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtonshoeid()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
int iSel;
|
|
|
CListBox *pCtrl;
|
|
|
HRESULT ht;
|
|
|
CString cstr;
|
|
|
|
|
|
if ((!m_ledhdl) || (!m_funLedScrShow))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
pCtrl = (CListBox *)GetDlgItem(IDC_LISTSHOWID);
|
|
|
|
|
|
iSel = pCtrl->GetCurSel();
|
|
|
if (LB_ERR == iSel)
|
|
|
{
|
|
|
MessageBox("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
ht = m_funLedScrShow(m_ledhdl, iSel+1);
|
|
|
if (ht < 0)
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD>ʾ<EFBFBD>̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD>ʾ<EFBFBD>̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳɹ<EFBFBD>";
|
|
|
}
|
|
|
ShowStates(cstr);
|
|
|
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtonshowlight()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
CEdit * pEdit;
|
|
|
int iRet;
|
|
|
CString cstr;
|
|
|
HRESULT ht;
|
|
|
char cval;
|
|
|
|
|
|
if ((!m_ledhdl) || (!m_funLedScrSetLight))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
pEdit = (CEdit *)(GetDlgItem(IDC_EDITLIGHT));
|
|
|
pEdit->GetWindowText(cstr);
|
|
|
|
|
|
|
|
|
iRet = atoi((LPCTSTR)cstr);
|
|
|
if (iRet > 255)
|
|
|
{
|
|
|
iRet = 255;
|
|
|
}
|
|
|
|
|
|
cval = (char)(iRet & 0xFF);
|
|
|
|
|
|
ht = m_funLedScrSetLight(m_ledhdl, cval);
|
|
|
if (ht < 0)
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>";
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>óɹ<EFBFBD>";
|
|
|
}
|
|
|
ShowStates(cstr);
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtonclose()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
|
|
|
CString cstr;
|
|
|
|
|
|
if ((!m_ledhdl) || (!m_funCloseLedScr))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
m_funCloseLedScr(m_ledhdl);
|
|
|
m_ledhdl =NULL;
|
|
|
cstr = "Led <20><> <20>ر<EFBFBD>";
|
|
|
ShowStates(cstr);
|
|
|
}
|
|
|
|
|
|
void CLedScreenTestDlg::ShowStates(CString & cstr)
|
|
|
{
|
|
|
CEdit * pEdit = (CEdit *)(GetDlgItem(IDC_EDITSTATES));
|
|
|
|
|
|
pEdit->SetWindowText(cstr);
|
|
|
}
|
|
|
|
|
|
|
|
|
void CLedScreenTestDlg::OnButtonstates()
|
|
|
{
|
|
|
// TODO: Add your control notification handler code here
|
|
|
|
|
|
int iret;
|
|
|
CString cstr;
|
|
|
HRESULT ht;
|
|
|
char cval;
|
|
|
|
|
|
if ((!m_ledhdl) || (!m_funLedScrGetStatus))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
ht = m_funLedScrGetStatus(m_ledhdl,&iret);
|
|
|
if (ht < 0)
|
|
|
{
|
|
|
|
|
|
cstr = "<EFBFBD><EFBFBD>ȡ״̬ʧ<EFBFBD><EFBFBD>";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cstr = "<EFBFBD><EFBFBD>ȡ״̬<EFBFBD>ɹ<EFBFBD> ״̬ = ";
|
|
|
if(0 == iret)
|
|
|
{
|
|
|
cstr += "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cstr += "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
ShowStates(cstr);
|
|
|
}
|