📄 inputline.cpp
字号:
// inputline.cpp : implementation file
//
#include "stdafx.h"
#include "PLC.h"
#include "inputline.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern char Order;//0=NOP;1=LD;2=LDI;3=AND;4=ANI;5=OR;6=ORI;7=ANB;
//8=ORB;9=OUT;10=SET;11=RST;12=MPS;13=MRD;14=MPP;15=END;
extern char Name;//0=X,1=Y,2=M,3=T,4=C;
extern unsigned short Code;
extern unsigned short Para;
extern char EnCa;
/////////////////////////////////////////////////////////////////////////////
// Cinputline dialog
Cinputline::Cinputline(CWnd* pParent /*=NULL*/)
: CDialog(Cinputline::IDD, pParent)
{
//{{AFX_DATA_INIT(Cinputline)
m_linecode = 0;
m_linepara = 0;
//}}AFX_DATA_INIT
}
void Cinputline::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cinputline)
DDX_Text(pDX, IDC_EDIT1, m_linecode);
DDX_Text(pDX, IDC_EDIT2, m_linepara);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cinputline, CDialog)
//{{AFX_MSG_MAP(Cinputline)
ON_WM_PAINT()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cinputline message handlers
BOOL Cinputline::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CComboBox*pCom1,*pCom2;
pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
pCom1->InsertString(0,"NOP");
pCom1->InsertString(1,"LD");
pCom1->InsertString(2,"LDI");
pCom1->InsertString(3,"AND");
pCom1->InsertString(4,"ANI");
pCom1->InsertString(5,"OR");
pCom1->InsertString(6,"ORI");
pCom1->InsertString(7,"ANB");
pCom1->InsertString(8,"ORB");
pCom1->InsertString(9,"OUT");
pCom1->InsertString(10,"SET");
pCom1->InsertString(11,"RST");
pCom1->InsertString(12,"MPS");
pCom1->InsertString(13,"MRD");
pCom1->InsertString(14,"MPP");
pCom1->InsertString(15,"END");
pCom1->SetCurSel(Order);
pCom2->InsertString(0,"X");
pCom2->InsertString(1,"Y");
pCom2->InsertString(2,"M");
pCom2->InsertString(3,"T");
pCom2->InsertString(4,"C");
pCom2->SetCurSel(Name);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//------------------------------------------------------------------------------------
void Cinputline::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CComboBox*pCom1,*pCom2;
pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
CEdit*pOne;
pOne=(CEdit*) GetDlgItem(IDC_EDIT1);
pOne->LimitText(3);
m_linecode=Code;
m_linepara=Para;
if((Order>=1)&&(Order<=11))
{pCom2->EnableWindow(true); pOne->EnableWindow(true);}
if((Order=9)&&(Name>=3))
{CEdit*pOnek; pOnek=(CEdit*) GetDlgItem(IDC_EDIT2); pOnek->EnableWindow(true);}
UpdateData(false);
pCom1->SetFocus();
// Do not call CDialog::OnPaint() for painting messages
}
//------------------------------------------------------------------------------------
void Cinputline::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
CComboBox*pCom1,*pCom2;
pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
Order=pCom1->GetCurSel();
Name=pCom2->GetCurSel();
Code=m_linecode;
Para=m_linepara;
if(Order==9)//OUT
{
if(Name==0) {AfxMessageBox("输出指令不能使用X寄存器"); return;}
}
else if(Order==10)//SET
{
if((Name==0)||(Name==3)||(Name==4)) {AfxMessageBox("置位指令不能使用X,T,C寄存器"); return;}
}
else if(Order==11)//RST
{
if(Name==0) {AfxMessageBox("复位指令不能使用X寄存器"); return;}
}
EnCa='E';
CDialog::OnOK();
}
//------------------------------------------------------------------------------------
void Cinputline::OnCancel()
{
// TODO: Add extra cleanup here
EnCa='C';
CDialog::OnCancel();
}
//------------------------------------------------------------------------------------
void Cinputline::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
CComboBox*pCom1,*pCom2;
pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
CEdit*pOne;
pOne=(CEdit*) GetDlgItem(IDC_EDIT1);
short value=pCom1->GetCurSel();
if((value>=1)&&(value<=11))
{
if(value==9)
{
value=pCom2->GetCurSel();
if(value>=3)
{CEdit*pOnek; pOnek=(CEdit*) GetDlgItem(IDC_EDIT2); pOnek->EnableWindow(true);}
value=pCom1->GetCurSel();
}
pCom2->EnableWindow(true); pOne->EnableWindow(true);
if((value>=1)&&(value<=8)) {pCom2->SetCurSel(0);}
else {pCom2->SetCurSel(1);}
}
else
{pCom2->EnableWindow(false); pOne->EnableWindow(false);}
// UpdateData(false);
}
//-------------------------------------------------------------------------------------
void Cinputline::OnSelchangeCombo2()
{
// TODO: Add your control notification handler code here
CComboBox*pCom1,*pCom2;
pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
short value=pCom1->GetCurSel();
if(value==9)
{
value=pCom2->GetCurSel();
if(value>=3)
{CEdit*pOnek; pOnek=(CEdit*) GetDlgItem(IDC_EDIT2); pOnek->EnableWindow(true);}
}
}
//--------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -