📄 signaladddlg.cpp
字号:
// SignalAddDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SignalAdd.h"
#include "SignalAddDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CSignalAddDlg dialog
CSignalAddDlg::CSignalAddDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSignalAddDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSignalAddDlg)
m_intAmp_1_1 = 0;
m_intAmp_1_2 = 0;
m_intAmp_1_3 = 0;
m_intAmp_1_4 = 0;
m_intAmp_1_5 = 0;
m_intAmp_2_1 = 0;
m_intAmp_2_2 = 0;
m_intAmp_2_3 = 0;
m_intAmp_2_4 = 0;
m_intAmp_2_5 = 0;
m_intAmp_3_1 = 0;
m_intAmp_3_10 = 0;
m_intAmp_3_2 = 0;
m_intAmp_3_3 = 0;
m_intAmp_3_4 = 0;
m_intAmp_3_5 = 0;
m_intAmp_3_6 = 0;
m_intAmp_3_7 = 0;
m_intAmp_3_8 = 0;
m_intAmp_3_9 = 0;
m_intRange_1_Begin = 0;
m_intRange_1_End = 0;
m_intRange_2_Begin = 0;
m_intRange_2_End = 0;
m_intRange_3_Begin = 0;
m_intRange_3_End = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSignalAddDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSignalAddDlg)
DDX_Text(pDX, IDC_EDIT_AMP_1_1, m_intAmp_1_1);
DDX_Text(pDX, IDC_EDIT_AMP_1_2, m_intAmp_1_2);
DDX_Text(pDX, IDC_EDIT_AMP_1_3, m_intAmp_1_3);
DDX_Text(pDX, IDC_EDIT_AMP_1_4, m_intAmp_1_4);
DDX_Text(pDX, IDC_EDIT_AMP_1_5, m_intAmp_1_5);
DDX_Text(pDX, IDC_EDIT_AMP_2_1, m_intAmp_2_1);
DDX_Text(pDX, IDC_EDIT_AMP_2_2, m_intAmp_2_2);
DDX_Text(pDX, IDC_EDIT_AMP_2_3, m_intAmp_2_3);
DDX_Text(pDX, IDC_EDIT_AMP_2_4, m_intAmp_2_4);
DDX_Text(pDX, IDC_EDIT_AMP_2_5, m_intAmp_2_5);
DDX_Text(pDX, IDC_EDIT_AMP_3_1, m_intAmp_3_1);
DDX_Text(pDX, IDC_EDIT_AMP_3_10, m_intAmp_3_10);
DDX_Text(pDX, IDC_EDIT_AMP_3_2, m_intAmp_3_2);
DDX_Text(pDX, IDC_EDIT_AMP_3_3, m_intAmp_3_3);
DDX_Text(pDX, IDC_EDIT_AMP_3_4, m_intAmp_3_4);
DDX_Text(pDX, IDC_EDIT_AMP_3_5, m_intAmp_3_5);
DDX_Text(pDX, IDC_EDIT_AMP_3_6, m_intAmp_3_6);
DDX_Text(pDX, IDC_EDIT_AMP_3_7, m_intAmp_3_7);
DDX_Text(pDX, IDC_EDIT_AMP_3_8, m_intAmp_3_8);
DDX_Text(pDX, IDC_EDIT_AMP_3_9, m_intAmp_3_9);
DDX_Text(pDX, IDC_EDIT_RANGE_1_BEGIN, m_intRange_1_Begin);
DDV_MinMaxInt(pDX, m_intRange_1_Begin, -4, 1);
DDX_Text(pDX, IDC_EDIT_RANGE_2_BEGIN, m_intRange_2_Begin);
DDV_MinMaxInt(pDX, m_intRange_2_Begin, -4, 1);
DDX_Text(pDX, IDC_EDIT_RANGE_3_BEGIN, m_intRange_3_Begin);
DDX_Text(pDX, IDC_EDIT_RANGE_1_END, m_intRange_1_End);
DDX_Text(pDX, IDC_EDIT_RANGE_2_END, m_intRange_2_End);
DDX_Text(pDX, IDC_EDIT_RANGE_3_END, m_intRange_3_End);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSignalAddDlg, CDialog)
//{{AFX_MSG_MAP(CSignalAddDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDADD, OnAdd)
ON_EN_KILLFOCUS(IDC_EDIT_RANGE_1_BEGIN, OnKillfocusEditRange1Begin)
ON_EN_UPDATE(IDC_EDIT_RANGE_2_BEGIN, OnUpdateEditRange2Begin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSignalAddDlg message handlers
BOOL CSignalAddDlg::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
return TRUE; // return TRUE unless you set the focus to a control
}
void CSignalAddDlg::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 CSignalAddDlg::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 CSignalAddDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSignalAddDlg::OnAdd()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);//获得1,2信号的范围和幅度
//更新范围
UpdateRange();
//更新幅度
UpdateAmp();
}
void CSignalAddDlg::OnKillfocusEditRange1Begin()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_intRange_1_End = m_intRange_1_Begin + 4;
UpdateData(FALSE);
}
void CSignalAddDlg::OnUpdateEditRange2Begin()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_UPDATE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_intRange_2_End = m_intRange_2_Begin + 4;
UpdateData(FALSE);
}
void CSignalAddDlg::UpdateRange()
{
m_intRange_3_Begin = (m_intRange_1_Begin > m_intRange_2_Begin ? m_intRange_2_Begin : m_intRange_1_Begin);//min
m_intRange_3_End = (m_intRange_1_End > m_intRange_2_End ? m_intRange_1_End : m_intRange_2_End);//max
UpdateData(FALSE);
}
void CSignalAddDlg::UpdateAmp()
{
int intR1Amp[5],intR2Amp[5],intR3Amp[10];
int i = 0;
intR1Amp[0] = m_intAmp_1_1;
intR1Amp[1] = m_intAmp_1_2;
intR1Amp[2] = m_intAmp_1_3;
intR1Amp[3] = m_intAmp_1_4;
intR1Amp[4] = m_intAmp_1_5;
intR2Amp[0] = m_intAmp_2_1;
intR2Amp[1] = m_intAmp_2_2;
intR2Amp[2] = m_intAmp_2_3;
intR2Amp[3] = m_intAmp_2_4;
intR2Amp[4] = m_intAmp_2_5;
intR3Amp[0] = m_intAmp_3_1;
intR3Amp[1] = m_intAmp_3_2;
intR3Amp[2] = m_intAmp_3_3;
intR3Amp[3] = m_intAmp_3_4;
intR3Amp[4] = m_intAmp_3_5;
intR3Amp[5] = m_intAmp_3_6;
intR3Amp[6] = m_intAmp_3_7;
intR3Amp[7] = m_intAmp_3_8;
intR3Amp[8] = m_intAmp_3_9;
intR3Amp[9] = m_intAmp_3_10;
for(i=0;i<5;i++)
{
intR3Amp[m_intRange_1_Begin + 4 + i] = intR1Amp[i];
}
for(i=0;i<5;i++)
{
intR3Amp[m_intRange_2_Begin + 4 + i] = intR3Amp[m_intRange_2_Begin + 4 + i] + intR2Amp[i];
}
m_intAmp_3_1 = intR3Amp[0];
m_intAmp_3_2 = intR3Amp[1];
m_intAmp_3_3 = intR3Amp[2];
m_intAmp_3_4 = intR3Amp[3];
m_intAmp_3_5 = intR3Amp[4];
m_intAmp_3_6 = intR3Amp[5];
m_intAmp_3_7 = intR3Amp[6];
m_intAmp_3_8 = intR3Amp[7];
m_intAmp_3_9 = intR3Amp[8];
m_intAmp_3_10 = intR3Amp[9];
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -