📄 irdlg.cpp
字号:
// IRDlg.cpp : implementation file
//
#include "stdafx.h"
#include "IR.h"
#include "IRDlg.h"
#include "IrPulse.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TIMEOUT 5000
/////////////////////////////////////////////////////////////////////////////
// CIRDlg dialog
CIRDlg::CIRDlg(CWnd* pParent /*=NULL*/)
: CDialog(CIRDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CIRDlg)
//}}AFX_DATA_INIT
int nPort=CIrPulse::FindIrPort();
m_nPort=(nPort>0) ? (nPort-1) : 2;
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CIRDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIRDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIRDlg, CDialog)
//{{AFX_MSG_MAP(CIRDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
ON_BN_CLICKED(IDC_BUTTON11, OnButton11)
ON_BN_CLICKED(IDC_BUTTON12, OnButton12)
ON_BN_CLICKED(IDC_BUTTON13, OnButton13)
ON_BN_CLICKED(IDC_BUTTON14, OnButton14)
ON_BN_CLICKED(IDC_BUTTON15, OnButton15)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIRDlg message handlers
BOOL CIRDlg::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 CIRDlg::OnButton1()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x90);
port.Close();
}
void CIRDlg::OnButton2()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x91);
port.Close();
}
void CIRDlg::OnButton3()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x92);
port.Close();
}
void CIRDlg::OnButton4()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x93);
port.Close();
}
void CIRDlg::OnButton5()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x80);
port.Close();
}
void CIRDlg::OnButton6()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x81);
port.Close();
}
void CIRDlg::OnButton7()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x82);
port.Close();
}
void CIRDlg::OnButton8()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x83);
port.Close();
}
void CIRDlg::OnButton9()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x84);
port.Close();
}
void CIRDlg::OnButton10()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x85);
port.Close();
}
void CIRDlg::OnButton11()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x86);
port.Close();
}
void CIRDlg::OnButton12()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x87);
port.Close();
}
void CIRDlg::OnButton13()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x88);
port.Close();
}
void CIRDlg::OnButton14()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x89);
port.Close();
}
void CIRDlg::OnButton15()
{
CIrPulse port;
if(!port.Open(m_nPort+1)) {
AfxMessageBox(_T("Failed to open irda port"));
return;
}
port.SetCodeSize(12);
port.SendCode(0x95);
port.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -