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
|
// PropPaths.cpp : implementation file
//
#define BITLBEE_CORE
#include "bitlbeewin.h"
#include "PropPaths.h"
#include "shlobj.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropPaths dialog
CPropPaths::CPropPaths()
: CPropertyPage(CPropPaths::IDD)
{
//{{AFX_DATA_INIT(CPropPaths)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CPropPaths::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropPaths)
DDX_Control(pDX, IDC_MOTDFILE, m_motdfile);
DDX_Control(pDX, IDC_EDIT_MOTD, m_edit_motd);
DDX_Control(pDX, IDC_CONFIGDIR, m_configdir);
DDX_Control(pDX, IDC_BROWSE_MOTD, m_browse_motd);
DDX_Control(pDX, IDC_BROWSE_CONFIG, m_browse_config);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropPaths, CPropertyPage)
//{{AFX_MSG_MAP(CPropPaths)
ON_BN_CLICKED(IDC_BROWSE_CONFIG, OnBrowseConfig)
ON_BN_CLICKED(IDC_BROWSE_MOTD, OnBrowseMotd)
ON_BN_CLICKED(IDC_EDIT_MOTD, OnEditMotd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropPaths message handlers
void CPropPaths::OnOK()
{
CString tmp;
g_free((void *)global.conf->configdir);
m_configdir.GetWindowText(tmp);
if (tmp.GetLength() > 0
&& tmp.GetAt(tmp.GetLength() - 1) != '/'
&& tmp.GetAt(tmp.GetLength() - 1) != '\\')
{
global.conf->configdir = g_strdup_printf("%s\\", tmp);
} else {
global.conf->configdir = g_strdup(tmp);
}
g_free((void *)global.conf->motdfile);
m_motdfile.GetWindowText(tmp);
global.conf->motdfile = g_strdup(tmp);
CPropertyPage::OnOK();
}
void CPropPaths::OnBrowseConfig()
{
BROWSEINFO bi = { 0 };
bi.lpszTitle = _T("Choose a config directory");
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if( pidl != 0)
{
TCHAR path[MAX_PATH];
if( SHGetPathFromIDList (pidl, path) ) {
m_configdir.SetWindowText(path);
}
IMalloc * imalloc = 0;
if ( SUCCEEDED (SHGetMalloc (&imalloc)) )
{
imalloc->Free(pidl);
imalloc->Release();
}
}
}
void CPropPaths::OnBrowseMotd()
{
CFileDialog f(TRUE);
if(f.DoModal() == IDOK) {
m_motdfile.SetWindowText(f.GetPathName());
}
}
void CPropPaths::OnEditMotd()
{
CString loc;m_motdfile.GetWindowText(loc);
ShellExecute(this->GetSafeHwnd(), NULL, loc, NULL, NULL, SW_SHOWNORMAL);
}
BOOL CPropPaths::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_configdir.SetWindowText(global.conf->configdir);
m_motdfile.SetWindowText(global.conf->motdfile);
return TRUE;
}
|