autoteachdelay.cpp

来自「机械手IPC控制器伺服运动程序」· C++ 代码 · 共 167 行

CPP
167
字号
// AutoTeachDelay.cpp : implementation file
//

#include "stdafx.h"
#include "alfa.h"
#include "AutoTeachDelay.h"
#include "AutoTeach.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAutoTeachDelay dialog


CAutoTeachDelay::CAutoTeachDelay(CWnd* pParent /*=NULL*/)
	: CDialog(CAutoTeachDelay::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAutoTeachDelay)
	m_mdelay = 0.0f;
	m_sdelay = 0.0f;
	//}}AFX_DATA_INIT
	m_nWidth=636;
	m_nHeight=120;
	m_nDx=106;
	m_nDy=20;
}


void CAutoTeachDelay::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAutoTeachDelay)
	DDX_Control(pDX, IDC_EDIT2, m_edt2);
	DDX_Control(pDX, IDC_EDIT1, m_edt1);
	DDX_Text(pDX, IDC_EDIT1, m_mdelay);
	DDX_Text(pDX, IDC_EDIT2, m_sdelay);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAutoTeachDelay, CDialog)
	//{{AFX_MSG_MAP(CAutoTeachDelay)
	ON_WM_SHOWWINDOW()
	ON_BN_CLICKED(IDC_BUTTON1, OnBtnOk)
	ON_BN_CLICKED(IDC_BUTTON2, OnBtnCancel)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAutoTeachDelay message handlers

void CAutoTeachDelay::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);

	CString Temp_str;
	// TODO: Add your message handler code here
	if(bShow!=1) return;
	CAutoTeach * parent=(CAutoTeach *)GetParent();
	int cursel=parent->Cursel;
	if(parent->command[cursel].mcommand.funid>=5 && 
	   parent->command[cursel].mcommand.funid<=17) {
		GetDlgItem(IDC_EDIT1)->EnableWindow();
        if(parent->command[cursel].mcommand.funid % 2==0)
			m_mdelay=parent->command[cursel].mcommand.para.dinoff;
		else if(parent->command[cursel].mcommand.funid <17)
			m_mdelay=parent->command[cursel].mcommand.para.dinon;
		else
			m_mdelay=parent->command[cursel].mcommand.para.mdelay;

	    Temp_str.Format("%6.2f", m_mdelay);
        GetDlgItem(IDC_EDIT1)->SetWindowText(Temp_str);

//		UpdateData(FALSE);
	}
	else
		GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
	if(parent->command[cursel].acommand.funid>=5 &&
	   parent->command[cursel].acommand.funid<=7) {
		GetDlgItem(IDC_EDIT2)->EnableWindow();
		if(parent->command[cursel].acommand.funid<7)
			m_sdelay=parent->command[cursel].acommand.para.dnip;
		else
			m_sdelay=parent->command[cursel].acommand.para.sdelay;
	    Temp_str.Format("%6.2f", m_sdelay);
        GetDlgItem(IDC_EDIT2)->SetWindowText(Temp_str);

//		UpdateData(FALSE);
	}
	else
		GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
	//
//	MoveWindow(13,405,0,0);
    //器    
//    SetTimer(1,5,NULL);
}

void CAutoTeachDelay::OnBtnOk() 
{
	// TODO: Add your control notification handler code here
	CAutoTeach * parent=(CAutoTeach *)GetParent();
	int cursel=parent->Cursel;
	UpdateData();
	if(GetDlgItem(IDC_EDIT1)->IsWindowEnabled()) {
		if(parent->command[cursel].mcommand.funid % 2==0)
			parent->command[cursel].mcommand.para.dinoff=m_mdelay;
		else if(parent->command[cursel].mcommand.funid<17)
			parent->command[cursel].mcommand.para.dinon=m_mdelay;
		else
			parent->command[cursel].mcommand.para.mdelay=m_mdelay;
	}
	if(GetDlgItem(IDC_EDIT2)->IsWindowEnabled()) {
		if(parent->command[cursel].acommand.funid<7)
			parent->command[cursel].acommand.para.dnip=m_sdelay;
		else
			parent->command[cursel].acommand.para.sdelay=m_sdelay;
	}
	parent->ShowCommand(cursel);
	parent->SaveRecords();
	ShowWindow(FALSE);
	dataflg=0;
	parent->dlgautoteachstatus->ShowWindow(TRUE);
}

void CAutoTeachDelay::OnBtnCancel() 
{
	// TODO: Add your control notification handler code here
	CAutoTeach * parent=(CAutoTeach *)GetParent();
	ShowWindow(FALSE);
	dataflg=0;
	parent->dlgautoteachstatus->ShowWindow(TRUE);
}

void CAutoTeachDelay::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	//获得此时窗口的实际大小
    CRect dlgRect;
    GetWindowRect(dlgRect);
	int width,height;
	width=dlgRect.Width();
	height=dlgRect.Height();
    //停止变化,关闭定时器1
    if((width >=m_nWidth) || (height >=m_nHeight))
		KillTimer(1); 
	else
     //如果是窗口弹出过程,则逐渐增大窗口
        MoveWindow(13, 405, m_nDx+dlgRect.Width(), 
		m_nDy+dlgRect.Height() );
	CDialog::OnTimer(nIDEvent);
}

BOOL CAutoTeachDelay::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	h_SkinDialog.SubClassDialog(m_hWnd);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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