-
Notifications
You must be signed in to change notification settings - Fork 2
/
DisciplineLetterTemplate.cpp
133 lines (105 loc) · 2.98 KB
/
DisciplineLetterTemplate.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// CDisciplineLetterTemplate.cpp : implementation file
//
#include "stdafx.h"
extern "C"{
#include "TMSHeader.h"
} // EXTERN C
#include "TMS.h"
#include "AddDialogs.h"
#include "AddDiscipline.h"
#include "Discipline.h"
#include "DisciplineLetter.h"
#include "DisciplineLetterTemplate.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDisciplineLetterTemplate dialog
CDisciplineLetterTemplate::CDisciplineLetterTemplate(CWnd* pParent, char* pszFile)
: CDialog(CDisciplineLetterTemplate::IDD, pParent)
{
m_pszFile = pszFile;
//{{AFX_DATA_INIT(CDisciplineLetterTemplate)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDisciplineLetterTemplate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDisciplineLetterTemplate)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDisciplineLetterTemplate, CDialog)
//{{AFX_MSG_MAP(CDisciplineLetterTemplate)
ON_LBN_DBLCLK(LETTERTEMPLATE_FILES, OnDblclkFiles)
ON_LBN_SELCHANGE(LETTERTEMPLATE_FILES, OnSelchangeFiles)
ON_BN_CLICKED(IDHELP, OnHelp)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDisciplineLetterTemplate message handlers
BOOL CDisciplineLetterTemplate::OnInitDialog()
{
CDialog::OnInitDialog();
//
// Set the pointers to the controls
//
pListBoxFILES = (CListBox *)GetDlgItem(LETTERTEMPLATE_FILES);
pEditPREVIEW = (CEdit *)GetDlgItem(LETTERTEMPLATE_PREVIEW);
//
// Display the file names
//
char path[MAX_PATH];
strcpy(path, szDisciplineLetterTemplateFolder);
DlgDirList(path, LETTERTEMPLATE_FILES, 0, 0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDisciplineLetterTemplate::OnDblclkFiles()
{
OnOK();
}
void CDisciplineLetterTemplate::OnSelchangeFiles()
{
DlgDirSelect(m_pszFile, LETTERTEMPLATE_FILES);
pEditPREVIEW->SetWindowText("");
//
// Open the text files for preview
//
CString inputLine, outputLine;
CString fileName;
CStdioFile Letter;
fileName = szDisciplineLetterTemplateFolder;
fileName += "\\";
fileName += m_pszFile;
Letter.Open(fileName, CFile::modeRead | CFile::typeText | CFile::shareDenyNone);
if(Letter.m_pStream)
{
Letter.SeekToBegin();
outputLine = "";
while(Letter.ReadString(inputLine))
{
outputLine += inputLine;
outputLine += "\r\n";
}
pEditPREVIEW->SetWindowText(outputLine);
Letter.Close();
}
}
void CDisciplineLetterTemplate::OnHelp()
{
// TODO: Add your control notification handler code here
}
void CDisciplineLetterTemplate::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CDisciplineLetterTemplate::OnOK()
{
DlgDirSelect(m_pszFile, LETTERTEMPLATE_FILES);
CDialog::OnOK();
}