📄 steelcutdlg.cpp
字号:
// Steel CutDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SteelCutSys.h"
#include "SteelCut.h"
#include "SteelCutDlg.h"
#include "DisposeDialog.h"
#include "SteelCutRun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CSteelCutSys g_CSteelCutSys;
CString g_IDC_COMBO[5];
CString g_IDC_EDIT_MC[5];
CString g_IDC[4];
CString g_IDC_EDIT_PL[5];
CString g_IDC_EDIT_PC[5];
char s_getstring[MAX_COUNT][MAX_COUNT];
TYPE_INFO TypeInfo[MAX_TYPE_COUNT] = {0};
int StructElement=0;
int Count=0;
CString AddINI;
/////////////////////////////////////////////////////////////////////////////
// CSteelCutDlg dialog
CSteelCutDlg::CSteelCutDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSteelCutDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSteelCutDlg)
m_edit_dia = 0;
m_edit_mcount1 = 0;
m_edit_mcount2 = 0;
m_edit_mcount3 = 0;
m_edit_mcount4 = 0;
m_edit_mcount5 = 0;
m_edit_pcount1 = 0;
m_edit_pcount2 = 0;
m_edit_pcount3 = 0;
m_edit_pcount4 = 0;
m_edit_pcount5 = 0;
m_edit_plen1 = 0;
m_edit_plen2 = 0;
m_edit_plen3 = 0;
m_edit_plen4 = 0;
m_edit_plen5 = 0;
m_combo_str1 = _T("");
m_combo_str2 = _T("");
m_combo_str3 = _T("");
m_combo_str4 = _T("");
m_combo_str5 = _T("");
m_edit_len = 0;
m_combo_mode_str = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSteelCutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSteelCutDlg)
DDX_Control(pDX, IDC_COMBO5, m_combo5);
DDX_Control(pDX, IDC_COMBO_MODE, m_combo_mode);
DDX_Control(pDX, IDC_COMBO4, m_combo4);
DDX_Control(pDX, IDC_COMBO3, m_combo3);
DDX_Control(pDX, IDC_COMBO2, m_combo2);
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Text(pDX, IDC_EDIT_DIA, m_edit_dia);
DDV_MinMaxUInt(pDX, m_edit_dia, 0, 4294967295);
DDX_Text(pDX, IDC_EDIT_MC1, m_edit_mcount1);
DDX_Text(pDX, IDC_EDIT_MC2, m_edit_mcount2);
DDX_Text(pDX, IDC_EDIT_MC3, m_edit_mcount3);
DDX_Text(pDX, IDC_EDIT_MC4, m_edit_mcount4);
DDX_Text(pDX, IDC_EDIT_MC5, m_edit_mcount5);
DDX_Text(pDX, IDC_EDIT_PC1, m_edit_pcount1);
DDX_Text(pDX, IDC_EDIT_PC2, m_edit_pcount2);
DDX_Text(pDX, IDC_EDIT_PC3, m_edit_pcount3);
DDX_Text(pDX, IDC_EDIT_PC4, m_edit_pcount4);
DDX_Text(pDX, IDC_EDIT_PC5, m_edit_pcount5);
DDX_Text(pDX, IDC_EDIT_PL1, m_edit_plen1);
DDX_Text(pDX, IDC_EDIT_PL2, m_edit_plen2);
DDX_Text(pDX, IDC_EDIT_PL3, m_edit_plen3);
DDX_Text(pDX, IDC_EDIT_PL4, m_edit_plen4);
DDX_Text(pDX, IDC_EDIT_PL5, m_edit_plen5);
DDX_CBString(pDX, IDC_COMBO1, m_combo_str1);
DDX_CBString(pDX, IDC_COMBO2, m_combo_str2);
DDX_CBString(pDX, IDC_COMBO3, m_combo_str3);
DDX_CBString(pDX, IDC_COMBO4, m_combo_str4);
DDX_CBString(pDX, IDC_COMBO5, m_combo_str5);
DDX_Text(pDX, IDC_EDIT_LEN, m_edit_len);
DDX_CBString(pDX, IDC_COMBO_MODE, m_combo_mode_str);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSteelCutDlg, CDialog)
//{{AFX_MSG_MAP(CSteelCutDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT_DIA, OnChangeEditDia)
ON_BN_CLICKED(IDUPDATE, OnUpdate)
ON_BN_CLICKED(IDDISPOSE, OnDispose)
ON_CBN_SELCHANGE(IDC_COMBO_MODE, OnSelchangeComboMode)
ON_CBN_SELENDOK(IDC_COMBO_MODE, OnSelendokComboMode)
ON_CBN_KILLFOCUS(IDC_COMBO1, OnKillfocusCombo1)
ON_CBN_KILLFOCUS(IDC_COMBO2, OnKillfocusCombo2)
ON_CBN_KILLFOCUS(IDC_COMBO3, OnKillfocusCombo3)
ON_CBN_KILLFOCUS(IDC_COMBO4, OnKillfocusCombo4)
ON_CBN_KILLFOCUS(IDC_COMBO5, OnKillfocusCombo5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSteelCutDlg message handlers
BOOL CSteelCutDlg::OnInitDialog()
{
int i;
CDialog::OnInitDialog();
// 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
/*init material len*/
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
for(i = 0;i <= Count-1;i++)
m_combo1.AddString(&s_getstring[i][0]);
m_combo1.SetCurSel(0);
for(i = 0;i <= Count-1;i++)
m_combo2.AddString(&s_getstring[i][0]);
m_combo2.SetCurSel(1);
for(i = 0;i <= Count-1;i++)
m_combo3.AddString(&s_getstring[i][0]);
m_combo3.SetCurSel(2);
for(i = 0;i <= Count-1;i++)
m_combo4.AddString(&s_getstring[i][0]);
m_combo4.SetCurSel(3);
for(i = 0;i <= Count-1;i++)
m_combo5.AddString(&s_getstring[i][0]);
m_combo5.SetCurSel(4);
/*Init cut type*/
g_CSteelCutSys.ParseINIFile(CUT_TYPE);
for(i = 0;i <= Count-1;i++)
{
m_combo_mode.AddString(&s_getstring[i][0]);
g_CSteelCutSys.ParseINIFile(&s_getstring[i][0]);
}
m_combo_mode.SetCurSel(0);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CSteelCutDlg::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 CSteelCutDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSteelCutDlg::OnOK()
{
GetDlgItem(IDC_COMBO1)->GetWindowText(g_IDC_COMBO[0]);
GetDlgItem(IDC_COMBO2)->GetWindowText(g_IDC_COMBO[1]);
GetDlgItem(IDC_COMBO3)->GetWindowText(g_IDC_COMBO[2]);
GetDlgItem(IDC_COMBO4)->GetWindowText(g_IDC_COMBO[3]);
GetDlgItem(IDC_COMBO5)->GetWindowText(g_IDC_COMBO[4]);
GetDlgItem(IDC_EDIT_MC1)->GetWindowText(g_IDC_EDIT_MC[0]);
GetDlgItem(IDC_EDIT_MC2)->GetWindowText(g_IDC_EDIT_MC[1]);
GetDlgItem(IDC_EDIT_MC3)->GetWindowText(g_IDC_EDIT_MC[2]);
GetDlgItem(IDC_EDIT_MC4)->GetWindowText(g_IDC_EDIT_MC[3]);
GetDlgItem(IDC_EDIT_MC5)->GetWindowText(g_IDC_EDIT_MC[4]);
GetDlgItem(IDC_EDIT_DIA)->GetWindowText(g_IDC[0]);
GetDlgItem(IDC_COMBO_MODE)->GetWindowText(g_IDC[1]);
GetDlgItem(IDC_EDIT_LEN)->GetWindowText(g_IDC[2]);
GetDlgItem(IDC_EDIT_PL1)->GetWindowText(g_IDC_EDIT_PL[0]);
GetDlgItem(IDC_EDIT_PL2)->GetWindowText(g_IDC_EDIT_PL[1]);
GetDlgItem(IDC_EDIT_PL3)->GetWindowText(g_IDC_EDIT_PL[2]);
GetDlgItem(IDC_EDIT_PL4)->GetWindowText(g_IDC_EDIT_PL[3]);
GetDlgItem(IDC_EDIT_PL5)->GetWindowText(g_IDC_EDIT_PL[4]);
GetDlgItem(IDC_EDIT_PC1)->GetWindowText(g_IDC_EDIT_PC[0]);
GetDlgItem(IDC_EDIT_PC2)->GetWindowText(g_IDC_EDIT_PC[1]);
GetDlgItem(IDC_EDIT_PC3)->GetWindowText(g_IDC_EDIT_PC[2]);
GetDlgItem(IDC_EDIT_PC4)->GetWindowText(g_IDC_EDIT_PC[3]);
GetDlgItem(IDC_EDIT_PC5)->GetWindowText(g_IDC_EDIT_PC[4]);
CSteelCut clsCSteelCut;
clsCSteelCut.Run();
// CDialog::OnOK();
}
CScrollBar* CSteelCutDlg::GetScrollBarCtrl(int nBar) const
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::GetScrollBarCtrl(nBar);
}
void CSteelCutDlg::OnChangeEditDia()
{
int i;
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
i = g_CSteelCutSys.TypeDefault(m_edit_dia);
m_combo_mode_str = TypeInfo[i].nName;
if(m_edit_dia >= TypeInfo[i].nDia)
m_edit_len = TypeInfo[i].nMaxLength;
else m_edit_len = TypeInfo[i].nMinLength;
UpdateData(FALSE);
}
void CSteelCutDlg::OnUpdate()
{
int i = 0;
char *chIDC_COMBO = (char*)malloc(100);
// TODO: Add your control notification handler code here
UpdateData(TRUE);
/* IF combo box1 Add Type*/
if(strcmp(m_combo_str1,""))
{
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
while(m_combo_str1 != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo1.AddString(m_combo_str1);
m_combo2.AddString(m_combo_str1);
m_combo3.AddString(m_combo_str1);
m_combo4.AddString(m_combo_str1);
m_combo5.AddString(m_combo_str1);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_str1);
g_CSteelCutSys.UpdateINIFile(MATERIAL_LEN,LIST_NAME,chIDC_COMBO);
}
}
/* IF combo box2 Add Type*/
if(strcmp(m_combo_str2,""))
{
i = 0;
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
while(m_combo_str2 != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo1.AddString(m_combo_str2);
m_combo2.AddString(m_combo_str2);
m_combo3.AddString(m_combo_str2);
m_combo4.AddString(m_combo_str2);
m_combo5.AddString(m_combo_str2);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_str2);
g_CSteelCutSys.UpdateINIFile(MATERIAL_LEN,LIST_NAME,chIDC_COMBO);
}
}
/*IF combo box3 Add Type*/
if(strcmp(m_combo_str3,""))
{
i = 0;
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
while(m_combo_str3 != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo1.AddString(m_combo_str3);
m_combo2.AddString(m_combo_str3);
m_combo3.AddString(m_combo_str3);
m_combo4.AddString(m_combo_str3);
m_combo5.AddString(m_combo_str3);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_str3);
g_CSteelCutSys.UpdateINIFile(MATERIAL_LEN,LIST_NAME,chIDC_COMBO);
}
}
/*IF combo box4 Add Type*/
if(strcmp(m_combo_str4,""))
{
i = 0;
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
while(m_combo_str4 != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo1.AddString(m_combo_str4);
m_combo2.AddString(m_combo_str4);
m_combo3.AddString(m_combo_str4);
m_combo4.AddString(m_combo_str4);
m_combo5.AddString(m_combo_str4);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_str4);
g_CSteelCutSys.UpdateINIFile(MATERIAL_LEN,LIST_NAME,chIDC_COMBO);
}
}
/*IF combo box5 Add Type*/
if(strcmp(m_combo_str5,""))
{
i = 0;
g_CSteelCutSys.ParseINIFile(MATERIAL_LEN);
while(m_combo_str5 != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo1.AddString(m_combo_str5);
m_combo2.AddString(m_combo_str5);
m_combo3.AddString(m_combo_str5);
m_combo4.AddString(m_combo_str5);
m_combo5.AddString(m_combo_str5);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_str5);
g_CSteelCutSys.UpdateINIFile(MATERIAL_LEN,LIST_NAME,chIDC_COMBO);
}
}
/*IF combo box mode Add Type*/
if(strcmp(m_combo_mode_str,""))
{
i = 0;
g_CSteelCutSys.ParseINIFile(CUT_TYPE);
while(m_combo_mode_str != &s_getstring[i][0] && i <= Count-1)
{
i++;
}
if(i == Count)
{
m_combo_mode.AddString(m_combo_mode_str);
*chIDC_COMBO = NULL;
strcat(chIDC_COMBO,m_combo_mode_str);
g_CSteelCutSys.UpdateINIFile(CUT_TYPE,LIST_NAME,chIDC_COMBO);
g_CSteelCutSys.UpdateINIFile(chIDC_COMBO,CUT_DIA,NO);
g_CSteelCutSys.UpdateINIFile(chIDC_COMBO,WEAR_LEN_MAX,NO);
g_CSteelCutSys.UpdateINIFile(chIDC_COMBO,WEAR_LEN_MIN,NO);
g_CSteelCutSys.ParseINIFile(chIDC_COMBO);
}
}
free(chIDC_COMBO);
}
void CSteelCutDlg::OnDispose()
{
// TODO: Add your control notification handler code here
CDisposeDialog dlg;
UpdateData(TRUE);
dlg.SetDlgTitle(m_combo_mode_str);
dlg.DoModal();
}
void CSteelCutDlg::OnSelchangeComboMode()
{
// TODO: Add your control notification handler code here
char *chIDC_COMBO_MODE = (char*)malloc(100);
int i;
// TODO: Add your control notification handler code here
*chIDC_COMBO_MODE = NULL;
int index = m_combo_mode.GetCurSel();
m_combo_mode.SetCurSel(index);
UpdateData(TRUE);
strcat(chIDC_COMBO_MODE,m_combo_mode_str);
for(i = 0; i <= StructElement; i++)
{
if(!strcmp(TypeInfo[i].nName,chIDC_COMBO_MODE))
{
if(m_edit_dia >= TypeInfo[i].nDia)
m_edit_len = TypeInfo[i].nMaxLength;
else m_edit_len = TypeInfo[i].nMinLength;
UpdateData(FALSE);
}
}
}
void CSteelCutDlg::OnSelendokComboMode()
{
}
void CSteelCutDlg::OnKillfocusCombo1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(strcmp(m_combo_str1,""))
{
if(!strcmp(m_combo_str1,m_combo_str2) ||
!strcmp(m_combo_str1,m_combo_str3) ||
!strcmp(m_combo_str1,m_combo_str4) ||
!strcmp(m_combo_str1,m_combo_str5))
{
MessageBox("该长度已经存在,请重新输入");
}
}
}
void CSteelCutDlg::OnKillfocusCombo2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(strcmp(m_combo_str2,""))
{
if(!strcmp(m_combo_str2,m_combo_str1) ||
!strcmp(m_combo_str2,m_combo_str3) ||
!strcmp(m_combo_str2,m_combo_str4) ||
!strcmp(m_combo_str2,m_combo_str5))
{
MessageBox("该长度已经存在,请重新输入");
}
}
}
void CSteelCutDlg::OnKillfocusCombo3()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(strcmp(m_combo_str3,""))
{
if(!strcmp(m_combo_str3,m_combo_str1) ||
!strcmp(m_combo_str3,m_combo_str2) ||
!strcmp(m_combo_str3,m_combo_str4) ||
!strcmp(m_combo_str3,m_combo_str5))
{
MessageBox("该长度已经存在,请重新输入");
}
}
}
void CSteelCutDlg::OnKillfocusCombo4()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(strcmp(m_combo_str4,""))
{
if(!strcmp(m_combo_str4,m_combo_str1) ||
!strcmp(m_combo_str4,m_combo_str2) ||
!strcmp(m_combo_str4,m_combo_str3) ||
!strcmp(m_combo_str4,m_combo_str5))
{
MessageBox("该长度已经存在,请重新输入");
}
}
}
void CSteelCutDlg::OnKillfocusCombo5()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(strcmp(m_combo_str5,""))
{
if(!strcmp(m_combo_str5,m_combo_str1) ||
!strcmp(m_combo_str5,m_combo_str2) ||
!strcmp(m_combo_str5,m_combo_str3) ||
!strcmp(m_combo_str5,m_combo_str4))
{
MessageBox("该长度已经存在,请重新输入");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -