www.pudn.com > roll.rar > ROLLDLG2.CPP


#include "stdafx.h" 
 
#include "roll.h" 
#include "bbroll.h" 
#include "rollDlg.h" 
#include "dynamic.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
void CBbemDlg::OnChangeParameter()  
{ 
	if(bEditing) 
		if(!PreButtonPush()) return; 
	unEnableEdit( bEditing ); 
	bEditing = !bEditing; 
	CButton* button=(CButton*)GetDlgItem(IDC_ChangeParameter); 
	if(bEditing) button->SetWindowText("Apply &Params"); 
	else button->SetWindowText("Change &Params"); 
} 
 
void CBbemDlg::unEnableEdit(BOOL bEnable) 
{ 
	CEdit* edit=(CEdit *)GetDlgItem(IDC_Z); 
	edit->SetReadOnly( bEnable ); 
	if(!bEnable) edit->SetFocus(); 
	edit=(CEdit *)GetDlgItem(IDC_R1); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_R2); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_LENGTH); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_ANGLE); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_HIGH); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_THICKNESS); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_LINSEG); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_ARCSEG); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_DEPSEG); 
	edit->SetReadOnly( bEnable ); 
	edit=(CEdit *)GetDlgItem(IDC_LARCSEG); 
	edit->SetReadOnly( bEnable ); 
} 
 
void CBbemDlg::OnChangeAngle()  
{ 
	bChange = TRUE;	 
} 
 
void CBbemDlg::OnChangeLength()  
{ 
	bChange = TRUE;	 
} 
 
void CBbemDlg::OnChangeHigh()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeR1()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeR2()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeZ()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeArcseg()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeLarcseg()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeDepseg()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeLinseg()  
{ 
	bChange = TRUE; 
} 
 
void CBbemDlg::OnChangeThickness()  
{ 
	bChange = TRUE; 
} 
 
template< class T > void Swap( T& a, T& b ) 
{ 
	T c; 
	c = a; a = b; b = c; 
} 
 
BOOL CBbemDlg::PreButtonPush() 
{ 
	if(bChange) { 
		bError=FALSE; 
		if(!UpdateData( TRUE )) return FALSE; 
		Swap(theRoll.m_angle,m_angle); 
		Swap(theRoll.m_thick,m_thick); 
		Swap(theRoll.m_high,m_high); 
		Swap(theRoll.m_length,m_length); 
		Swap(theRoll.m_r1,m_r1); 
		Swap(theRoll.m_r2,m_r2); 
		Swap(theRoll.m_teethnum,m_teethnum); 
		Swap(theRoll.m_LINSEG,m_LINSEG); 
		Swap(theRoll.m_ARCSEG,m_ARCSEG); 
		Swap(theRoll.m_DEPSEG,m_DEPSEG); 
		Swap(theRoll.m_LARCSEG,m_LARCSEG); 
		if(theRoll.Calc_Roller()) { 
			bError=TRUE; 
			Swap(theRoll.m_angle,m_angle); 
			Swap(theRoll.m_thick,m_thick); 
			Swap(theRoll.m_high,m_high); 
			Swap(theRoll.m_length,m_length); 
			Swap(theRoll.m_r1,m_r1); 
			Swap(theRoll.m_r2,m_r2); 
			Swap(theRoll.m_teethnum,m_teethnum); 
			Swap(theRoll.m_LINSEG,m_LINSEG); 
			Swap(theRoll.m_ARCSEG,m_ARCSEG); 
			Swap(theRoll.m_DEPSEG,m_DEPSEG); 
			Swap(theRoll.m_LARCSEG,m_LARCSEG); 
		} 
		else { 
			if(!theRoll.WriteParameters(this)) return FALSE; 
			bChange = FALSE; 
		} 
	} 
	if(bError) { 
		char buf[150]; 
		sprintf(buf,"The roller parameters are uncorrect!\nYou must change the roller geometry parameters.\nThe wall max-radius=%12.3f",theRoll.m_tthick); 
		MessageBox(buf,"Error",MB_ICONSTOP|MB_OK); 
		return FALSE; 
	} 
	return TRUE; 
}