📄 demodlg.cpp
字号:
// demoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "demo.h"
#include "demoDlg.h"
#include "ceddk.h"
#include <atlconv.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog
CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemoDlg)
// 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 CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemoDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
//{{AFX_MSG_MAP(CDemoDlg)
ON_BN_CLICKED(IDC_SEND, OnSend)
ON_BN_CLICKED(IDC_PULSE, OnPulse)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers
BOOL CDemoDlg::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
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CDemoDlg::SendValue(bool b)
{
CEdit *tPort = (CEdit*)GetDlgItem(IDC_PORT);
CEdit *tValue = (CEdit*)GetDlgItem(IDC_VALUE);
CString p;
CString v;
tPort->GetWindowText(p);
tValue->GetWindowText(v);
CString p_str;
p_str.Format(_T("0x%s"),p);
CString v_str;
v_str.Format(_T("0x%s"),v);
int port = _ttoi(p_str);
int value = _ttoi(v_str);
PUCHAR Port=(PUCHAR)port;
UCHAR Value=0x0;
Value=
READ_PORT_UCHAR(
Port
);
if(b)
Value=value;
else
Value=!value;
WRITE_PORT_UCHAR(
Port,
Value
);
Value=0x0;
READ_PORT_UCHAR(
Port
);
}
bool bo = true;
void CDemoDlg::OnSend()
{
// TODO: Add your control notification handler code here
if(bo)
{
SendValue(true);
bo = !bo;
//MessageBox(_T("Send Positive"));
}
else
{
SendValue(false);
bo = !bo;
//MessageBox(_T("Send Inverse"));
}
}
bool s;
void CDemoDlg::OnPulse()
{
// TODO: Add your control notification handler code here
CEdit *tSecond = (CEdit*)GetDlgItem(IDC_TIMER);
CString str;
tSecond->GetWindowText(str);
int second = _ttoi(str);
s = true;
SendValue(true);
SetTimer(1,second,NULL);
}
void CDemoDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call defaut
if(s)
{
SendValue(false);
s = !s;
}
else
{
SendValue(true);
s = !s;
}
CDialog::OnTimer(nIDEvent);
}
void CDemoDlg::OnCancel()
{
// TODO: Add your control notification handler code here
SendValue(true);
KillTimer(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -