-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cpp
executable file
·109 lines (95 loc) · 2.29 KB
/
Settings.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
// Settings.cpp : implementation file
//
#include "stdafx.h"
#include "ghost xpress.h"
#include "Settings.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSettings dialog
CSettings::CSettings(CWnd* pParent /*=NULL*/)
: CDialog(CSettings::IDD, pParent)
{
//{{AFX_DATA_INIT(CSettings)
//}}AFX_DATA_INIT
}
void CSettings::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSettings)
DDX_Control(pDX, IDC_CATALOGS, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSettings, CDialog)
//{{AFX_MSG_MAP(CSettings)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSettings message handlers
BOOL CSettings::OnInitDialog()
{
CDialog::OnInitDialog();
m_list.SetExtendedStyle(LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
m_list.DeleteAllItems();
WIN32_FIND_DATA fd;
HANDLE hnd=FindFirstFile(".\\Catalog\\*.gxc",&fd);
if(hnd == INVALID_HANDLE_VALUE)
{
MessageBox("No Calalog Created","Error",MB_OK|MB_ICONSTOP);
}
int pos=0;
do
{
if(fd.cFileName[0] != _T('.'))
{
CString s=fd.cFileName;
int pos=s.ReverseFind(_T('.'));
s.Delete(pos,s.GetLength()-pos);
m_list.InsertItem(0, s);
}
}while(FindNextFile(hnd,&fd));
FindClose(hnd);
pos=m_list.GetNextItem(-1,LVNI_ALL);
do
{
m_list.SetCheck(pos);
pos=m_list.GetNextItem(pos,LVNI_ALL);
}while(pos!=-1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSettings::OnRefresh()
{
OnInitDialog();
}
void CSettings::OnOK()
{
cats.Empty();
int pos=m_list.GetNextItem(-1,LVNI_ALL);
do
{
if(m_list.GetCheck(pos))
{
cats+=m_list.GetItemText(pos,0);
cats+=";";
}
pos=m_list.GetNextItem(pos,LVNI_ALL);
}while(pos!=-1);
CDialog::OnOK();
}
void CSettings::OnCancel()
{
cats.Empty();
int pos=m_list.GetNextItem(-1,LVNI_ALL);
do
{
cats+=m_list.GetItemText(pos,0);
cats+=";";
pos=m_list.GetNextItem(pos,LVNI_ALL);
}while(pos!=-1);
CDialog::OnCancel();
}