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

📄 inputpart.cpp

📁 可以编辑PLC梯形图
💻 CPP
字号:
// inputpart.cpp : implementation file
//

#include "stdafx.h"
#include "PLC.h"
#include "inputpart.h"

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

extern char PartKind, partName, EnterCancel;
extern short PartCode, Partpara;
/////////////////////////////////////////////////////////////////////////////
// Cinputpart dialog


Cinputpart::Cinputpart(CWnd* pParent /*=NULL*/)
	: CDialog(Cinputpart::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cinputpart)
	m_partcode = 0;
	m_partpara = 0;
	//}}AFX_DATA_INIT
}


void Cinputpart::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cinputpart)
	DDX_Text(pDX, IDC_EDIT1, m_partcode);
	DDX_Text(pDX, IDC_EDIT2, m_partpara);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cinputpart, CDialog)
	//{{AFX_MSG_MAP(Cinputpart)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cinputpart message handlers
BOOL Cinputpart::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CComboBox*pCom1,*pCom2; 
	pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
	pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
	pCom1->InsertString(0,"---| |---");
	pCom1->InsertString(1,"---|/|---");
	pCom1->InsertString(2,"---[   ]");
	pCom1->InsertString(3,"---[ S ]");
	pCom1->InsertString(4,"---[ R ]");
	pCom1->SetCurSel(PartKind-2); 
	pCom2->InsertString(0,"X");
	pCom2->InsertString(1,"Y");
	pCom2->InsertString(2,"M");
	pCom2->InsertString(3,"T");
	pCom2->InsertString(4,"C");	
	pCom2->SetCurSel(partName);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
//-----------------------------------------------------------------------
void Cinputpart::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CEdit*pOne; 
	pOne=(CEdit*) GetDlgItem(IDC_EDIT1);
	pOne->LimitText(3);
    pOne->SetFocus();
    m_partcode=PartCode;
	UpdateData(false);	
	pOne->SetSel(0,-1,false);
	// Do not call CDialog::OnPaint() for painting messages
}
//----------------------------------------------------------------------
void Cinputpart::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);	
	CComboBox*pCom1,*pCom2; 
	pCom1=(CComboBox*) GetDlgItem(IDC_COMBO1);
	pCom2=(CComboBox*) GetDlgItem(IDC_COMBO2);
	PartKind=pCom1->GetCurSel()+2;
	partName=pCom2->GetCurSel(); 
    PartCode=m_partcode;
    Partpara=m_partpara;

	if(PartKind==4)//-[]
	{
		if(partName==0) {AfxMessageBox("输出指令不能使用X寄存器"); return;}
	}
	else if(PartKind==5)//-[S]
	{
		if((partName==0)||(partName==3)||(partName==4)) 
			{AfxMessageBox("置位指令不能使用X,T,C寄存器"); return;}
	}
	else if(PartKind==6)//-[R]
	{
		if(partName==0) {AfxMessageBox("复位指令不能使用X寄存器"); return;}
	}

    EnterCancel='E';
	CDialog::OnOK();
}
//---------------------------------------------------------------------
void Cinputpart::OnCancel() 
{
	// TODO: Add extra cleanup here
	EnterCancel='C';
	CDialog::OnCancel();
}
//-----------------------------------------------------------------------

⌨️ 快捷键说明

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