-
Notifications
You must be signed in to change notification settings - Fork 2
/
ReadBarCodeDialog.cpp
111 lines (87 loc) · 2.55 KB
/
ReadBarCodeDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// ReadBarCodeDialog.cpp : implementation file
//
#include "stdafx.h"
#include "ColorEyeI.h"
#include "ReadBarCodeDialog.h"
#include "MainFrm.h"
#include "ColorEyeIDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CReadBarCodeDialog dialog
CReadBarCodeDialog::CReadBarCodeDialog(CWnd* pParent /*=NULL*/)
: CDialog(CReadBarCodeDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CReadBarCodeDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CReadBarCodeDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReadBarCodeDialog)
DDX_Control(pDX, IDC_STATIC_BARCODE, m_stcBarCode);
DDX_Control(pDX, IDC_COMBO_SELNO, m_cbxNo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReadBarCodeDialog, CDialog)
//{{AFX_MSG_MAP(CReadBarCodeDialog)
ON_CBN_SELCHANGE(IDC_COMBO_SELNO, OnSelchangeComboSelno)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReadBarCodeDialog message handlers
void CReadBarCodeDialog::initBarCodeList()
{
CColorEyeIApp* pApp = dynamic_cast<CColorEyeIApp*>(AfxGetApp());
ASSERT_VALID(pApp);
m_PathName.Format("%s\\BarCode.txt", pApp->GetPath());
CTxtFile fTxt;
CFileException fx;
if (fTxt.Open(m_PathName, fx))
{
fTxt.oTxtData(m_Barcodelsit);
fTxt.Close();
}
else
CDialog::OnCancel();
CString str;
for (int i = 0; i < m_Barcodelsit.size(); ++i)
{
str.Format("%d", i);
m_cbxNo.AddString(str);
}
m_Barcodelsit.push_back("");
m_cbxNo.AddString("null");
}
void CReadBarCodeDialog::OnSelchangeComboSelno()
{
// TODO: Add your control notification handler code here
m_stcBarCode.SetWindowText(m_Barcodelsit.at(m_cbxNo.GetCurSel()));
}
BOOL CReadBarCodeDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
initBarCodeList();
m_cbxNo.SetCurSel(m_cbxNo.GetCount()-1);
OnSelchangeComboSelno();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CReadBarCodeDialog::OnOK()
{
// TODO: Add extra validation here
CMainFrame* pMainFrm = dynamic_cast<CMainFrame*>(AfxGetMainWnd());
ASSERT_VALID(pMainFrm);
CColorEyeIDoc* pDoc = dynamic_cast<CColorEyeIDoc*>(pMainFrm->GetActiveDocument());
ASSERT_VALID(pDoc);
CString pnlId;
m_stcBarCode.GetWindowText(pnlId);
pnlId.TrimRight();
pDoc->GetFileHead().iPnlID(pnlId);
CDialog::OnOK();
}