📄 zibian1dlg.cpp
字号:
// zibian1Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "zibian1.h"
#include "zibian1Dlg.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()
/////////////////////////////////////////////////////////////////////////////
// CZibian1Dlg dialog
CZibian1Dlg::CZibian1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CZibian1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZibian1Dlg)
m_dl1 = 1.0f;
m_dl2 = 1.0f;
m_dl3 = 1.0f;
m_dl4 = 1.0f;
m_dl5 = 1.0f;
m_dl6 = 1.0f;
m_dy1 = 0.0f;
m_dy2 = 0.0f;
m_dy3 = 0.0f;
m_dy4 = 0.0f;
m_dy5 = 0.0f;
m_dy6 = 0.0f;
m_valRecv1 = 0.0f;
m_valRecv2 = 0.0f;
m_valRecv3 = 0.0f;
m_valRecv4 = 0.0f;
m_valRecv5 = 0.0f;
m_valRecv6 = 0.0f;
m_num=0;
m_valNum1 = _T("无设备");
m_valNum2 = _T("无设备");
m_valNum3 = _T("无设备");
m_valNum4 = _T("无设备");
m_valNum5 = _T("无设备");
m_valNum6 = _T("无设备");
m_a=0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CZibian1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZibian1Dlg)
DDX_Control(pDX, IDC_SetSTATICl6, m_setstatic6);
DDX_Control(pDX, IDC_SetSTATICl5, m_setstatic5);
DDX_Control(pDX, IDC_SetSTATICl4, m_setstatic4);
DDX_Control(pDX, IDC_SetSTATICl3, m_setstatic3);
DDX_Control(pDX, IDC_SetSTATICl2, m_setstatic2);
DDX_Control(pDX, IDC_SetSTATICl1, m_setstatic1);
DDX_Control(pDX, IDC_RECVEDIT6, m_ctrlRecvEdit6);
DDX_Control(pDX, IDC_RECVEDIT5, m_ctrlRecvEdit5);
DDX_Control(pDX, IDC_RECVEDIT4, m_ctrlRecvEdit4);
DDX_Control(pDX, IDC_RECVEDIT3, m_ctrlRecvEdit3);
DDX_Control(pDX, IDC_RECVEDIT2, m_ctrlRecvEdit2);
DDX_Control(pDX, IDC_RECVEDIT1, m_ctrlRecvEdit1);
DDX_Control(pDX, IDC_RECV6, m_ctrlRecv6);
DDX_Control(pDX, IDC_RECV5, m_ctrlRecv5);
DDX_Control(pDX, IDC_RECV4, m_ctrlRecv4);
DDX_Control(pDX, IDC_RECV3, m_ctrlRecv3);
DDX_Control(pDX, IDC_RECV2, m_ctrlRecv2);
DDX_Control(pDX, IDC_RECV1, m_ctrlRecv1);
DDX_Text(pDX, IDC_dianliu1, m_dl1);
DDV_MinMaxFloat(pDX, m_dl1, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianliu2, m_dl2);
DDV_MinMaxFloat(pDX, m_dl2, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianliu3, m_dl3);
DDV_MinMaxFloat(pDX, m_dl3, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianliu4, m_dl4);
DDV_MinMaxFloat(pDX, m_dl4, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianliu5, m_dl5);
DDV_MinMaxFloat(pDX, m_dl5, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianliu6, m_dl6);
DDV_MinMaxFloat(pDX, m_dl6, 0.f, 1000.f);
DDX_Text(pDX, IDC_dianya1, m_dy1);
DDX_Text(pDX, IDC_dianya2, m_dy2);
DDX_Text(pDX, IDC_dianya3, m_dy3);
DDX_Text(pDX, IDC_dianya4, m_dy4);
DDX_Text(pDX, IDC_dianya5, m_dy5);
DDX_Text(pDX, IDC_dianya6, m_dy6);
DDX_Control(pDX, IDC_MSCOMM1, m_comm);
DDX_Text(pDX, IDC_RECVEDIT1, m_valRecv1);
DDX_Text(pDX, IDC_RECVEDIT2, m_valRecv2);
DDX_Text(pDX, IDC_RECVEDIT3, m_valRecv3);
DDX_Text(pDX, IDC_RECVEDIT4, m_valRecv4);
DDX_Text(pDX, IDC_RECVEDIT5, m_valRecv5);
DDX_Text(pDX, IDC_RECVEDIT6, m_valRecv6);
DDX_Text(pDX, IDC_NUM1, m_valNum1);
DDX_Text(pDX, IDC_NUM2, m_valNum2);
DDX_Text(pDX, IDC_NUM3, m_valNum3);
DDX_Text(pDX, IDC_NUM4, m_valNum4);
DDX_Text(pDX, IDC_NUM5, m_valNum5);
DDX_Text(pDX, IDC_NUM6, m_valNum6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZibian1Dlg, CDialog)
//{{AFX_MSG_MAP(CZibian1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON2, OnSet)
ON_BN_CLICKED(IDC_BUTTON3, OnMeasure)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_JIAZAI, OnJiazai)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZibian1Dlg message handlers
BOOL CZibian1Dlg::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
for (int n=0;n<100;n++)
{
myshow[n].count= 0;
myshow[n].setdianliu=1.0f;
myshow[n].reptNum = 0;
}
GetDlgItem(IDC_dianya1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu1)->EnableWindow(FALSE);
GetDlgItem(IDC_dianliu2)->EnableWindow(FALSE);
GetDlgItem(IDC_dianliu3)->EnableWindow(FALSE);
GetDlgItem(IDC_dianliu4)->EnableWindow(FALSE);
GetDlgItem(IDC_dianliu5)->EnableWindow(FALSE);
GetDlgItem(IDC_dianliu6)->EnableWindow(FALSE);
GetDlgItem(IDC_RECV1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT6)->ShowWindow(SW_HIDE);
m_comm.SetInBufferSize(512); //接收缓冲区
m_comm.SetOutBufferSize(512);//发送缓冲区
if(m_comm.GetPortOpen())
m_comm.SetPortOpen(FALSE);
m_comm.SetCommPort(1); //选择COM1
if( !m_comm.GetPortOpen())
m_comm.SetPortOpen(TRUE);//打开串口
else
AfxMessageBox("cannot open serial port");
m_comm.SetInputLen(0);//设置当前接收区数据长度为0,表示全部读取
m_comm.SetInputMode(1);//以二进制方式读写数据
m_comm.SetRThreshold(1);//接收缓冲区有1个及1个以上字符时,将引发接收数据的OnComm事件
m_comm.SetSettings("9600,n,8,1");//波特率9600无检验位,8个数据位,1个停止位
m_comm.GetInput();//先预读缓冲区以清除残留数据
SetTimer(1,300,NULL);
SetTimer(2,10,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CZibian1Dlg::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 CZibian1Dlg::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 CZibian1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CZibian1Dlg::OnSet()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_dianliu1) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu2) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu3) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu4) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu5) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu6) -> EnableWindow(TRUE);
GetDlgItem(IDC_dianliu1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_dianliu2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_dianliu3)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_dianliu4)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_dianliu5)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_dianliu6)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl3)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl4)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl5)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SetSTATICl6)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_RECV1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECV6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_RECVEDIT6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianya6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATICy6)->ShowWindow(SW_HIDE);
KillTimer(1);
}
void CZibian1Dlg::OnMeasure()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_dianliu1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_dianliu6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl2)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl3)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl4)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl5)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SetSTATICl6)->ShowWindow(SW_HIDE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -