⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test232dlg.cpp

📁 模拟数字硬盘录像机部分功能
💻 CPP
字号:
// test232Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "test232.h"
#include "test232Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTest232Dlg dialog

CTest232Dlg::CTest232Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTest232Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTest232Dlg)
		// 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 CTest232Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTest232Dlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTest232Dlg, CDialog)
	//{{AFX_MSG_MAP(CTest232Dlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_Monitor1, OnMonitor1)
	ON_BN_CLICKED(IDC_Monitor2, OnMonitor2)
	ON_BN_CLICKED(IDC_Monitor3, OnMonitor3)
	ON_BN_CLICKED(IDC_Monitor4, OnMonitor4)
	ON_BN_CLICKED(IDC_Up, OnUp)
	ON_BN_CLICKED(IDC_Down, OnDown)
	ON_BN_CLICKED(IDC_Left, OnLeft)
	ON_BN_CLICKED(IDC_Right, OnRight)
	ON_BN_CLICKED(IDC_Middle, OnMiddle)
	ON_BN_CLICKED(IDC_Close, OnClose)
	ON_BN_CLICKED(IDC_Open, OnOpen)
	ON_BN_CLICKED(IDC_Near, OnNear)
	ON_BN_CLICKED(IDC_Far, OnFar)
	ON_BN_CLICKED(IDC_Wide, OnWide)
	ON_BN_CLICKED(IDC_Tele, OnTele)
	ON_BN_CLICKED(IDC_Off, OnOff)
	ON_BN_CLICKED(IDC_On, OnOn)
	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)
	ON_BN_CLICKED(IDC_BUTTON16, OnButton16)
	ON_BN_CLICKED(IDC_YuntaiControl, OnYuntaiControl)
	ON_BN_CLICKED(IDC_VcrControl, OnVcrControl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTest232Dlg message handlers

BOOL CTest232Dlg::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
	com.Open(2);  //打开串口2并使用默认设置
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// 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 CTest232Dlg::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();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CTest232Dlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CTest232Dlg::OnMonitor1() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==1)
	{
	BYTE str[20];
	str[0] = 0x80;
	str[1] = 0x80;
	str[2] = 0x00;
	str[3] = 0x00;
	str[4] = 0x00;
	str[5] = 0x80;
	str[6] = 0x00;
	str[7] = 0x00;
	str[8] = 0x00;
	str[9] = 0x80;
	
	com.Write(str , 10);
	}
	else
	MonitorNum=0;
}

void CTest232Dlg::OnMonitor2() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==1)
	{
	BYTE str[20];
	str[0] = 0x80;
	str[1] = 0x80;
	str[2] = 0x00;
	str[3] = 0x00;
	str[4] = 0x00;
	str[5] = 0x00;
	str[6] = 0x00;
	str[7] = 0x00;
	str[8] = 0x00;
	str[9] = 0x80;
	com.Write(str , 10);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnMonitor3() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==1)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80};
	com.Write(str,10);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnMonitor4() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==1)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80};
	com.Write(str,10);
	}
	else
	MonitorNum=0;
}

void CTest232Dlg::OnUp() 
{
	// TODO: Add your control notification handler code here

    if(Ctrl==2)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80};
	com.Write(str,10);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnDown() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80};
	com.Write(str,9);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnLeft() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x80};
	com.Write(str,10);
	}
    else 
    MonitorNum=0;
}

void CTest232Dlg::OnRight() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80};
	com.Write(str,9);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnMiddle() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0x80,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80};
	com.Write(str,10);
	}
	else 
	MonitorNum=0;
}

void CTest232Dlg::OnClose() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}

}

void CTest232Dlg::OnOpen() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}
	

}

void CTest232Dlg::OnNear() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}

}

void CTest232Dlg::OnFar() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}

}

void CTest232Dlg::OnWide() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X80,0X00,0X00,0X00,0X80};
	com.Write(str,11);
	}
	
}

void CTest232Dlg::OnTele() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}
    
}

void CTest232Dlg::OnOff() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X00,0X80};
	com.Write(str,10);
	}

}

void CTest232Dlg::OnOn() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X80,0X00,0X00,0X80};
	com.Write(str,10);
	}
    
}

void CTest232Dlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton4() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton5() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton6() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0x80,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton7() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0x00,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton9() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton10() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnButton11() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0x00,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton12() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0x80,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton13() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0X80,0X80,0X00,0X00,0X80};
	com.Write(str,11);
	}
}

void CTest232Dlg::OnButton14() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X80,0x00,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton15() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0x00,0X00,0X00,0X80};
	com.Write(str,10);
	}
}

void CTest232Dlg::OnButton16() 
{
	// TODO: Add your control notification handler code here
	if(Ctrl==2)
	{
	BYTE str[20]={0x80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X80};
	com.Write(str,9);
	}
}

void CTest232Dlg::OnYuntaiControl() 
{
	// TODO: Add your control notification handler code here
Ctrl=1;
}

void CTest232Dlg::OnVcrControl() 
{
	// TODO: Add your control notification handler code here
Ctrl=2;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -