📄 mfcappdlg.cpp
字号:
void CMFCAppDlg::OnBuzzer()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
char buff[16];
ULONG nOutput;
buff[0]=0x03;
buff[1]=!m_buzzer;
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
}
void CMFCAppDlg::OnChangeLeft()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::OnChangeRight()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::OnChangelcd1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
// if(m_lcd1.GetLength()==0)return;
if(!IsE(&m_lcd1))
{
MessageBox("只能输入英文字符");
m_lcd1="";
UpdateData(FALSE);
}
char buff[18];
ULONG nWritten;
memset(buff,' ',18*sizeof(char));
buff[0]=1;
buff[1]=1;
for(int i=0;i!=m_lcd1.GetLength();i++)buff[i+2]=m_lcd1.GetAt(i);
WriteFile(hDevice, buff, 18, &nWritten, NULL);
// TODO: Add your control notification handler code here
}
BOOL CMFCAppDlg::IsE(CString * str)
{
for(int i=0;i!=str->GetLength();i++)
if(str->GetAt(i)>255||str->GetAt(i)<0)return FALSE;
return TRUE;
}
void CMFCAppDlg::OnChangeLcd2()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
// if(m_lcd1.GetLength()==0)return;
if(!IsE(&m_lcd2))
{
MessageBox("只能输入英文字符");
m_lcd2="";
UpdateData(FALSE);
}
char buff[18];
ULONG nWritten;
memset(buff,' ',18*sizeof(char));
buff[0]=1;
buff[1]=2;
for(int i=0;i!=m_lcd2.GetLength();i++)buff[i+2]=m_lcd2.GetAt(i);
WriteFile(hDevice, buff, 18, &nWritten, NULL);
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::Onsw0()
{
// TODO: Add your control notification handler code here
sw=0;
Onsw();
m_EDIT5="0";
}
void CMFCAppDlg::Onsw1()
{
// TODO: Add your control notification handler code here
sw=1;
Onsw();
m_EDIT5="1";
}
void CMFCAppDlg::Onsw2()
{
// TODO: Add your control notification handler code here
sw=2;
Onsw();
m_EDIT5="2";
}
void CMFCAppDlg::Onsw3()
{
// TODO: Add your control notification handler code here
sw=3;
Onsw();
m_EDIT5="3";
}
void CMFCAppDlg::Onsw4()
{
// TODO: Add your control notification handler code here
sw=4;
Onsw();
m_EDIT5="4";
}
void CMFCAppDlg::Onsw5()
{
// TODO: Add your control notification handler code here
sw=5;
Onsw();
m_EDIT5="5";
}
void CMFCAppDlg::Onsw6()
{
// TODO: Add your control notification handler code here
sw=6;
Onsw();
m_EDIT5="6";
}
void CMFCAppDlg::Onsw7()
{
// TODO: Add your control notification handler code here
sw=7;
Onsw();
m_EDIT5="7";
}
void CMFCAppDlg::Onsw8()
{
// TODO: Add your control notification handler code here
sw=8;
Onsw();
m_EDIT5="8";
}
void CMFCAppDlg::Onsw9()
{
// TODO: Add your control notification handler code here
sw=9;
Onsw();
m_EDIT5="9";
}
void CMFCAppDlg::Onsw10()
{
// TODO: Add your control notification handler code here
sw=10;
Onsw();
m_EDIT5="A";
}
void CMFCAppDlg::Onsw11()
{
// TODO: Add your control notification handler code here
sw=11;
Onsw();
m_EDIT5="B";
}
void CMFCAppDlg::Onsw12()
{
// TODO: Add your control notification handler code here
sw=12;
Onsw();
m_EDIT5="C";
}
void CMFCAppDlg::Onsw13()
{
// TODO: Add your control notification handler code here
sw=13;
Onsw();
m_EDIT5="D";
}
void CMFCAppDlg::Onsw14()
{
// TODO: Add your control notification handler code here
sw=14;
Onsw();
m_EDIT5="E";
}
void CMFCAppDlg::Onsw15()
{
// TODO: Add your control notification handler code here
sw=15;
Onsw();
m_EDIT5="F";
}
void CMFCAppDlg::Onsw()
{
char buff[16];
CHAR bufOutput[16]; // Output from device
ULONG nOutput;
buff[0]=0x02;
buff[1]=sw;
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
bufOutput,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
}
void CMFCAppDlg::OnChangeEdit6()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::OnChangeEdit7()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::OnChangeEdit8()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::OnChangeEdit9()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateData();
if(m_left.GetLength()==0||m_right.GetLength()==0||m_edit6.GetLength()==0||m_edit7.GetLength()==0||m_edit8.GetLength()==0||m_edit9.GetLength()==0) return;
char buff[16];
ULONG nOutput;
buff[0]=0x04;
buff[1]=m_left.GetAt(0)-'0';
buff[2]=m_right.GetAt(0)-'0';
buff[3]=m_edit6.GetAt(0)-'0';
buff[4]=m_edit7.GetAt(0)-'0';
buff[5]=m_edit8.GetAt(0)-'0';
buff[6]=m_edit9.GetAt(0)-'0';
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Write,
buff,
16,
NULL,
0,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
// TODO: Add your control notification handler code here
}
void CMFCAppDlg::wendu()
{
char wen; // Output from device
ULONG nOutput;
if (!DeviceIoControl(hDevice,
FORUSB_IOCTL_Read,
NULL,
0,
&wen,
1,
&nOutput,
NULL)
)
{
m_Mes="ERROR: DeviceIoControl returns .";
UpdateData(FALSE);
}
m_wendu=wen;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -